简体   繁体   English

在多元时间预测 LSTM 模型中预测未来值

[英]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.我对如何使用时间序列多元 LSTM 模型预测未来结果感到困惑。

I am trying to build a model for a stock market prediction and I have the following data features我正在尝试建立一个股票市场预测模型,我有以下数据特征

Date DailyHighPrice DailyLowPrice Volume ClosePrice日期 DailyHighPrice DailyLowPrice 成交量 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.如果我用 5 年的数据训练我的模型直到今天,我想预测明天的收盘价,基本上我需要预测明天的所有数据特征。 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. 在使用LSTM之前,最好也了解RNN的实现。

The tensorflow documentation has some examples of a RNNs and LSTM implementations: https://www.tensorflow.org/tutorials/sequences/recurrent tensorflow文档包含一些RNN和LSTM实现的示例: 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. 在这里查看Jason Brownlee的精彩文章,并提供您所要求的示例。 https://machinelearningmastery.com/multivariate-time-series-forecasting-lstms-keras/ 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. 即,提取n天输入的窗口,并在n + 1天输出标签,例如n = 7。 Then the RNN or LSTM will train on these extracted windows as samples (training data). 然后,RNN或LSTM将在这些提取的窗口上作为样本进行训练(训练数据)。

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). 最后,您当然可以在最近的n天历史数据上使用经过训练的网络来预测接下来几天的功能(模型部署)。

See also this SO post: Understanding Keras LSTMs 另请参见此 SO帖子: 了解Keras LSTM

The solution I decided to go with here is a TimeseriesGenerator from the keras library. 我决定使用的解决方案是来自keras库的TimeseriesGenerator。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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