我通過將資料集拆分為訓練和測驗來訓練我的股票價格預測模型。我還通過將有效資料與預測資料進行比較來測驗預測,并且該模型運行良好。但我想預測未來的實際價值。
我需要在下面的代碼中更改什么?
如何在實際未來的特定日期做出預測?
代碼(在 Jupyter Notebook 中):
(要運行代碼,請在您擁有的類似 csv 檔案中嘗試,或使用命令安裝 nsepy python 庫pip install nsepy)
# imports
import pandas as pd # data processing
import numpy as np # linear algebra
import matplotlib.pyplot as plt # plotting
from datetime import date # date
from nsepy import get_history # NSE historical data
from keras.models import Sequential # neural network
from keras.layers import LSTM, Dropout, Dense # LSTM layer
from sklearn.preprocessing import MinMaxScaler # scaling
nseCode = 'TCS'
stockTitle = 'Tata Consultancy Services'
# API call
apiData = get_history(symbol = nseCode, start = date(2017,1,1), end = date(2021,12,19))
data = apiData # copy the dataframe (not necessary)
# remove columns you don't need
del data['Symbol']
del data['Series']
del data['Prev Close']
del data['Volume']
del data['Turnover']
del data['Trades']
del data['Deliverable Volume']
del data['
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/391410.html
