[英]LSTM - Multivariate Time Series Predictions
I was reading the tutorial on Multivariate Time Series Forecasting with LSTMs in Keras https://machinelearningmastery.com/multivariate-time-series-forecasting-lstms-keras/#comment-442845 我正在阅读Keras中关于LSTM的多变量时间序列预测的教程https://machinelearningmastery.com/multivariate-time-series-forecasting-lstms-keras/#comment-442845
I have followed through the entire tutorial and got stuck with a problem which is as follows- 我遵循了整个教程,并陷入了如下问题:
In this tutorial, the train and test splits have 8 features viz., 'pollution', 'dew', 'temp', 'press', 'wnd_dir', 'wnd_spd', 'snow', 'rain' at step 't-1', while the output feature is 'pollution' at current step 't'. 在本教程中,训练和测试拆分具有8个功能,即在步骤“ t”处的“污染”,“露水”,“温度”,“压力”,“ wnd_dir”,“ wnd_spd”,“雪”和“雨” -1”,而输出特征在当前步骤“ t”处为“污染”。 This is because, the framing of the dataset as a supervised learning problem is about predicting the 'pollution' at current hour/time step 't', given the pollution and weather measurements at the prior hour/time step 't-1' 这是因为,给定前一小时/时间步骤“ t-1”的污染和天气测量值,将数据集作为监督学习问题的框架是关于预测当前小时/时间步骤“ t”的“污染”
After fitting the model to the training and testing data splits, what if I want to make predictions for a new dataset having 7 features since it does not have 'pollution' feature in it and I explicitly just want to predict for this one feature using the other 7 features. 在将模型拟合到训练和测试数据分割之后,如果我要对具有7个特征的新数据集进行预测,因为该模型中没有“污染”特征,而我明确地只想使用其他7个功能。
Thanks for your help! 谢谢你的帮助!
How do I handle such a situation? 我该如何处理这种情况? (while the remaining 7 features remain the same) (而其余7个功能保持不变)
Edit- Assume that my dataset has the following 3 features while training/fitting the model- shop_number, item_number, number_of_units_sold 编辑-假设我的数据集在训练/拟合模型时具有以下3个特征-shop_number,item_number,number_of_units_sold
AFTER, I have trained the LSTM model, I get a dataset having the features- 'shop_number' AND 'item_number'. 之后,我训练了LSTM模型,得到了一个具有“ shop_number”和“ item_number”特征的数据集。 The dataset DOES NOT have 'number_of_units_sold'. 数据集不具有“ number_of_units_sold”。
The 'input_shape' argument in 'LSTM' has 1 as time step and 3 as features while training. “ LSTM”中的“ input_shape”参数在训练时具有1个时间步长和3个特征。 But while predicting, I have 1 time step but ONLY 2 features (as 'number_of_units_sold' is what I have to predict). 但是在预测时,我只有1个时间步长,但只有2个特征(因为我必须预测“ number_of_units_sold”)。
So how should I proceed? 那么我该如何进行呢?
If pollution is the last feature: 如果污染是最后一个特征:
X = original_data[:,:,:-1]
Y = original_data[:,:,-1:]
If pollution is the first feature 如果污染是首要特征
X = original_data[:,:,1:]
Y = original_data[:,:,:1]
Else 其他
i = index_of_pollution_feature
X = np.concatenate([original_data[:,:,:i], original_data[:,:,i+1:],axis=-1)
Y = original_data[:,:,i:i+1]
Make a model with return_sequences=True
, stative=False
and that's it. 用return_sequences=True
, stative=False
制作模型,仅此而已。 Don't use Flatten, Global poolings or anything that removes the steps dimension. 不要使用Flatten,Global池或任何删除步长维度的东西。
If you don't have any pollution data at all for training, then you can't. 如果您根本没有任何污染数据需要培训,那么您就不能这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.