简体   繁体   中英

Predicting future values in a multivariate time forecasting LSTM model

I am confused on how to predict future results with a time series multivariate LSTM model.

I am trying to build a model for a stock market prediction and I have the following data features

Date DailyHighPrice DailyLowPrice Volume ClosePrice

If I train my model on 5 years of data up until today and I want to predict tomorrows ClosePrice, essentially I will need to predict all the data features for tomorrow. This is where I am confused.... Because if all the data features are dependent on one another how do i predict for one day in the future when all the data features for tomorrow are still unknown? Does anyone have any example code on how to deal with this issue?

Before using LSTM's it is good to also understand the implementation of a RNN.

The tensorflow documentation has some examples of a RNNs and LSTM implementations: https://www.tensorflow.org/tutorials/sequences/recurrent

You are partially correct, the output is indeed dependent on "all" the previous input. But, this doesn't have to mean all the previous input. See here an excellent post by Jason Brownlee with examples of the kind you're asking for. https://machinelearningmastery.com/multivariate-time-series-forecasting-lstms-keras/

Usually you "partition" your dataset into episodes. Ie, extract windows of n days of input with an output label at the n+1 day, for eg n=7. Then the RNN or LSTM will train on these extracted windows as samples (training data).

Finally, you will of-course use the trained network on the most recent n-day history data to predict your features for the following days (model deployment).

See also this SO post: Understanding Keras LSTMs

The solution I decided to go with here is a TimeseriesGenerator from the keras library.

https://machinelearningmastery.com/how-to-use-the-timeseriesgenerator-for-time-series-forecasting-in-keras/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM