我想从九个输入变量预测一个输出变量。这个数据也是一个时间序列,目标是预测输出变量提前2个步骤。
我使用均值归一化对所有数据进行了规范化并添加了一些功能,所以现在数据看起来像这样:
weekday (weekend vs weekday) hour (f_real - 50)*70 ACE [Mwh] \
0 -1.579094 -1.341627 0.032171 2.017604
1 -1.579094 -0.447209 0.032171 -0.543702
2 -1.579094 0.447209 0.037651 0.204731
3 -1.579094 1.341627 0.043130 -0.601538
4 -1.579094 -1.341627 0.021211 11.759046
IGCC [Mwh] SRE [Mwh] TertCalls [Mwh] Imbalance [Mwh] Time
0 0.257560 5.377617 0.128754 -2.858935 -1.713381
1 0.507353 4.850718 0.128754 -2.532608 -1.677292
2 0.173518 5.042090 0.128754 -3.325708 -1.641203
3 2.753128 1.684767 0.128754 -2.912524 -1.605114
4 0.206732 6.506615 0.128754 -4.926271 -1.569025
和这样的目标:
0 1.541263
1 1.541263
2 1.541263
3 1.541263
4 3.885717
Name: TRE [Mwh], dtype: float64
现在我的问题来了。如果我以这种格式将X和y数据提供给LSTM模型,它可以很好地学习如何预测目标变量。
但是当我执行2次步移时:
target = target.shift(-2)
它只是学习了同样的东西,并预测目标落后2个步骤。
两种型号都是使用Keras制造的LSTM网络:
model = Sequential()
model.add(LSTM(50, input_shape=(1, train_X.shape[2])))
model.add(Dense(1, activation='linear'))
model.compile(loss='mse', optimizer=Adam(lr=0.02))
model.fit(train_X, train_y, epochs=200, batch_size=train_X.shape[0]//2, verbose=2)
有没有办法,例如修改成本函数以帮助模型预测转移的目标?