I want to predict one output variable from nine input variables. This data is also a time series and the goal is to predict the output variable 2 timesteps ahead.
I normalised all data using mean normalisation and added some features so now the data look like this:
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
and the target like this:
0 1.541263
1 1.541263
2 1.541263
3 1.541263
4 3.885717
Name: TRE [Mwh], dtype: float64
Now here comes my problem. If I feed X and y data to the LSTM model in this format it learns perfectly how to predict the target variable throughout time.
But when I perform shift by 2 timesteps with:
target = target.shift(-2)
It just learns sort of the same thing and predicts the target 2 timesteps behind.
Both models are the same LSTM network made using Keras:
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)
Is there any way to e.g. modify the cost function to help the model predict the shifted target?