JordiCorbilla/stock-prediction-deep-neural-learning

Nice demo of LSTM: Question

vijaycd opened this issue · 2 comments

After wrangling for two weeks off and on with my Win10/Conda env, finally, your code runs great (without GPU even though I have it).

  1. It creates all these folders when I run your code.
  2. I see all the graphs being drawn
  3. I see the last prediction.png also drawn.
    Q: But, how do I introduce granularity or more user-friendliness into the predictions.csv file? In other words, I want to see predictions day by day displayed on the graph or in the CSV file by date? So, which file do I need to tweak to make that happen?

EXAMPLE (GOOG), "Actual" values below are not actual ! Just random ones.

Date / Actual / Predicted
...
Feb 21 / 90.22 / 90.78
Feb 22 / 91.44 / 91.55
Feb 23 / 93.55 / 95.93 (today)
Feb 24 / ------ / 95.01 (future)
Feb 25 / ------- / 95.50 (future)
Feb 26 / ....
Mar 19
say (30 days forward)

How do I do it?

Thanks for providing this code for me to experiment with (I am trying to understand how it works).

So you need to consider the nature of the LSTM as it will give you an output for next day. This will help you validate your signals.

To test the model output for tomorrow, you would need to feed the model with the most recent data point and use it to make a prediction. Here is an example of how to do this in Python (there should be a prediction example in my solution)

# import necessary libraries
import pandas as pd
from keras.models import load_model

# load the saved model
model = load_model('model.h5')

# load the most recent data point
data = pd.read_csv('data.csv')
latest_data = data.tail(1)

# preprocess the data (normalize, standardize, etc.)
# ... 

# create the input tensor
# ...

# make the prediction
prediction = model.predict(input_tensor)

# print the predicted value
print('Tomorrow\'s stock price prediction:', prediction)

In the code above, you would first load the saved model using the load_model() function from the Keras library. Then, you would load the most recent data point and preprocess it as needed to create the input tensor. Finally, you would use the predict() method of the model to make a prediction for tomorrow's stock price, and print the result to the console.

Thank you. I guess I have to normalize/standardize the same way as you have in your trained model before the prediction.