Hello Quantra Team, in the Course Neural Networks in Trading Section 6 Unit 14 on LSTM, could you confirm the below code as to me it would make sense to use the last value [-1] in each block to get the predicted value and not the first value [0].
My suggestion would be
predicted_close = []
for i in range(len(predict_close)):
predicted_close.append((predict_close[i][-1][0]))
predicted_close
The code in the course is this one:
predicted_close = []
for i in range(len(predict_close)):
predicted_close.append((predict_close[i][0][0]))
predicted_close
Hello Adrien,
Regarding your query about the LSTM code, here are insights into using [0] versus [-1] in the predicted arrays for different purposes. Let's break them into prediction and evaluation.
For prediction:
Using [0]:
This retrieves the predicted value for the immediate next time step after the input sequence.
This approach is straightforward and suitable for analysing immediate next-step predictions, minimising potential error accumulation.
Using [-1]:
This retrieves the predicted value for the furthest point (20th time step) in the forecast horizon:
While useful for evaluating long-term forecasting capabilities, [-1] may involve more accumulated errors over multiple steps.
For Evaluation:
Using [0]: For evaluating the model's short-term accuracy and generating immediate trading strategies, [0] is typically preferred. It directly compares predicted values with actual values for the immediate next time step.
Using [-1]: If assessing the model's performance over a longer forecast horizon is your goal, [-1] provides insights into its ability to forecast further into the future.
However, to generate meaningful insights or trading spreads using long-term predictions, it's crucial to compare these predictions with the 20th value from the current time step in test data.
Now, let's understand the code in the notebook.
In the notebook, we emphasised the use of [0] to analyse immediate next-step predictions and compared them with corresponding values in the test dataset for generating spread.
Feel free to let us know if you have more questions or need further clarification on this topic.