Predicting future values with a multivariate LSTM model

Viewed 742

I come to ask a question concerning the future predictions with an LSTM models

I explain to you :

I am using an LSTM model to predict the stock price for the next 36 hours.

I have a dataset with 10 features.

I use these 10 features as inputs in my model with a single output (the expected price).

Here is my overall model:

model = Sequential()
 
# input shape == (336, 10), I use 336 hours for my lookback and 10 features

model.add(LSTM(units=50,return_sequences=True,input_shape=(X_train.shape[1], X_train.shape[2])))
  model.add(Dropout(0.2))
  model.add(LSTM(units=50,return_sequences=True))
  model.add(Dropout(0.2))
  model.add(LSTM(units=50,return_sequences=True))
  model.add(Dropout(0.2))
  model.add(LSTM(units=50))
  model.add(Dropout(0.2))
  model.add(Dense(units=1, activation='linear'))
  model.compile(optimizer='adam',loss='mean_squared_error')

I can assess the performance of my model with my test data, but now I would like to use it to predict the next 36 hours, that's the goal anyway, isn't it?

And there I have the impression that there is a big black hole on the internet, everyone presents how to build models and test them with the test data but nobody uses them...

I found two interesting examples which consist in re-integrating the prediction into the last window iteratively.

Here are the examples at the bottom of the topics:

https://towardsdatascience.com/time-series-forecasting-with-recurrent-neural-networks-74674e289816 https://towardsdatascience.com/using-lstms-to-forecast-time-series-4ab688386b1f

In itself it works but with only one feature as input.

I have 10 features, my model just returns me an output value so I cannot reintegrate it into the last window which expects 10 features in its shape.

Do you see the problem?

I really hope you can orient me on the subject.

Adrien

0 Answers
Related