One method for predicting stock prices is using a long short-term memory neural network (LSTM) for times series forecasting. We’ll use a combination of AI calculations to forecast this company’s future stock price with LSTM.
The Appl data is from 2015-05-27 up to 22-05-2020. We take the close column for the stock prediction. We can use the same strategy.
The training size should be 65% of the total length of the data frame, the test size should be the difference between the length of the dataset and the training size.
Now the timestep value will be 100. We split the data X, Y. In the 0th iteration the first 100 elements goes as your first record and the 101 elements will be put up in the X. The 100 elements will be put up in the Y.
The input gate: The input gate adds information to the cell state, The forget gate: It removes the information that is no longer required by the model, The output gate: Output Gate at LSTM selects the information to be shown as output.
The values in train predict and test predict. I got,i am just plotting it:
A. Green indicates the Predicted Data
B. Blue indicates the Complete Data
C. Orange indicates the Train Data