I tried to implement LSTM model for time-series prediction. Below is my trial code. This code runs without error.

metrics = ['mean_squared_error', 'mean_absolute_error', 'mean_absolute_percentage_error']

# define model
model = Sequential()
model.summary()


)

The forecast correctly predicts the peaks, but the constant values ​​should be 0 and you cannot predict it.

However, prediction is extremely poor. How to improve the predictin? Do you have any ideas to improve it? Any ideas for improving prediction by re-designing architecture and/or layers?

• The last layer generates 2 outputs, what are they with respect to the final prediction?
– noe
Dec 7, 2020 at 20:10
• yes it generates 2 outputs. this is a time series problem, the 2 departures are the next 2 hours. @ncasas Dec 9, 2020 at 10:24

Your loss function estimates the conditional expectation and the predictions mainly hover around the mean of the time series. I would argue that predictions are good, but the problem is poorly designed. One approach would be to partition the problem into two subproblems: probability of your series being $$\mathbb{P}(Y>0)$$ and predicting the conditional expectation by training only on non-zero values $$\mathbb{E}[Y|Y>0]$$. The final prediction would then be $$\mathbb{P}(Y>0)\mathbb{E}[Y|Y>0]$$