国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
機(jī)器學(xué)習(xí)項(xiàng)目實(shí)戰(zhàn)【機(jī)器學(xué)習(xí)預(yù)測(cè)股價(jià)】

機(jī)器學(xué)習(xí)項(xiàng)目實(shí)戰(zhàn)系列機(jī)器學(xué)習(xí)預(yù)測(cè)股價(jià)

目錄

機(jī)器學(xué)習(xí)項(xiàng)目實(shí)戰(zhàn)系列 機(jī)器學(xué)習(xí)預(yù)測(cè)股價(jià)

一、概述

二、分析數(shù)據(jù)

1.導(dǎo)入

2.數(shù)據(jù)導(dǎo)入

3.分析股票尾市數(shù)據(jù)

4.構(gòu)建模型

5.測(cè)試模型

6.展示預(yù)測(cè)結(jié)果

一、概述

根據(jù)上一年的數(shù)據(jù)預(yù)測(cè)股票市場(chǎng)的未來價(jià)格

數(shù)據(jù)集:股票價(jià)格預(yù)測(cè)數(shù)據(jù)集:Two Sigma: Using News to Predict Stock Movements | Kaggle

源代碼:股票價(jià)格預(yù)測(cè)項(xiàng)目:Just a moment...


二、分析數(shù)據(jù)

1.導(dǎo)入

import pandas as pdimport numpy as np import matplotlib.pyplot as plt%matplotlib inline from matplotlib.pylab import rcParamsrcParams['figure.figsize']=20,10from keras.models import Sequentialfrom keras.layers import LSTM,Dropout,Dense from sklearn.preprocessing import MinMaxScaler

2.數(shù)據(jù)導(dǎo)入

3.分析股票尾市數(shù)據(jù)

df['Date']=pd.to_datetime(df.Date,format='%Y-%m-%d')df.index=df['Date'] plt.figure(figsize=(16,8))plt.plot(df['Close'],label='Close Price history')

4.構(gòu)建模型

import math#Create a new dataframe with only the Close columndata = df.filter(['Close'])#Convert the dataframe to a numpy arraydataset = data.values #Get the number of rows to train the modeltraining_data_len = math.ceil( len(dataset) * .8)training_data_len
#Scale the datascaler=MinMaxScaler(feature_range=(0,1))scaled_data=scaler.fit_transform(dataset) scaled_data
#Create the training data set#Create the scaled training data settrain_data = scaled_data[0:training_data_len , :]#Split the data into x_train and y_train data setsx_train = []y_train = [] for i in range(60,len(train_data)): x_train.append(train_data[i-60:i,0]) y_train.append(train_data[i,0]) if i<= 60: print(x_train) print(y_train) print()
#Build the LSTM modelmodel = Sequential()model.add(LSTM(50,return_sequences=True,input_shape=(x_train.shape[1],1)))model.add(LSTM(50,return_sequences=False))model.add(Dense(25))model.add(Dense(1))

5.測(cè)試模型

#Create the testing data set#Create a new array containing scaled values from index 1543 to 2003test_data = scaled_data[training_data_len - 60: , :]#Create the data sets x_test and y_testx_test = []y_test = dataset[training_data_len: , :]for i in range(60, len(test_data)): x_test.append(test_data[i-60:i,0])
#Get the models predicted price valuespredictions = model.predict(x_test)predictions = scaler.inverse_transform(predictions)

6.展示預(yù)測(cè)結(jié)果

#Plot the datatrain = data[:training_data_len]valid = data[training_data_len:]valid['Predictions'] = predictions#Visualize the dataplt.figure(figsize=(16,8))plt.title('Model')plt.xlabel('Date', fontsize=18)plt.ylabel('Close Prise USD ($)', fontsize=18)plt.plot(train['Close'])plt.plot(valid[['Close', 'Predictions']])plt.legend(['Train','Val','Predictions'], loc='lower right')plt.show()
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
用機(jī)器學(xué)習(xí)預(yù)測(cè)股市:為什么僅僅是歷史回測(cè)準(zhǔn)確率高?
以深度學(xué)習(xí)和機(jī)器學(xué)習(xí) 分析預(yù)測(cè)股市(附代碼)
一文全覽機(jī)器學(xué)習(xí)建模流程(Python代碼)
【R語(yǔ)言】隨機(jī)森林代碼
Time and Series Forecasting with LSTM
ARIMA與LSTM:用電量的預(yù)測(cè)
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服