Home > Blockchain >  How to predict actual future values after testing the trained LSTM model?
How to predict actual future values after testing the trained LSTM model?

Time:12-23

I have trained my stock price prediction model by splitting the dataset into train & test. I have also tested the predictions by comparing the valid data with the predicted data, and the model works fine. But I want to predict actual future values.

What do I need to change in my code below?

How can I make predictions up to a specific date in the actual future?


Code (in a Jupyter Notebook):

(To run the code, please try it in a similar csv file you have, or install nsepy python library using command 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['           
  • Related