I am currently encountering issues with formulating a prediction beyond my validation set. When utilizing a validation set, my model works fine and I am able to achieve a credible prediction.
However, I am attempting to utilize a loop in order to predict for the future but I am running into issues where my results seem to graph similar to a logarithmic function (attached).
The reference code I have attached below is the segment of code that I am currently running into problems with. I would appreciate any assistance in understanding what the problem in my code is.
predicted_prices = []
current_sequence = df.Price[-window_size:].values.reshape(-1, 1)
current_sequence = scaler.transform(current_sequence)
current_sequence = np.reshape(current_sequence, (1, window_size, 1))
for _ in range((prediction_end_date - prediction_start_date).days):
prediction = LSTM_model.predict(current_sequence)
predicted_prices.append(prediction[0, 0])
current_sequence = np.concatenate((current_sequence[:, 1:, :], np.reshape(prediction, (1, 1, 1))), axis=1)
predicted_prices = scaler.inverse_transform(np.array(predicted_prices).reshape(-1, 1))
prediction_dates = pd.date_range(start=prediction_start_date, end=prediction_end_date - pd.DateOffset(days=1))
I attempted to solve a similar problem as the post I have attached below, however, my approach to utilize the given solutions is not working.
Keras LSTM: how to predict beyond validation vs predictions?
Ranveer Hothi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.