Skip to content Skip to sidebar Skip to footer

Is This Correctly Work On Predict Next Value In Keras?

here is my code ... look_back = 20 train_size = int(len(data) * 0.80) test_size = len(data) - train_size train = data[0:train_size] test = data[train_size:len(data)] x_train, y_tr

Solution 1:

According to your code you are trying to predict next value using lstm. So here you have to reshape your input data correctly to reflect the time steps and features.

model.add(LSTM(512,  return_sequences=True))

instead of this code you have to write :

model.add(LSTM(512, input_shape=(look_back,x)))

x = input features in your training data.

I guess this article will help to moderate your code and predict the future value:

enter link description here

This article will help you to understand more about how to predict future value:

enter link description here

Thank you

Solution 2:

There are multiple methods you can try. There is no one right way at the moment. You can train a seperate model for predicting t+1, t+2 ... t+n. One LSTM model predicts t+1 while another predicts t+n. That is called a DIRMO strategy.

Your strategy (recursive strategy) is particularly risky because the model can propagate the error through multiple time horizons.

You can find a good comparison of alternative strategies in this paper. https://www.sciencedirect.com/science/article/pii/S0957417412000528?via%3Dihub

Post a Comment for "Is This Correctly Work On Predict Next Value In Keras?"