Using LSTM to do time series data prediction get wrong output

Hello, when I do the time series data prediction using LSTM model, the outcome is pretty confusing for me. I want predict the one month’ electricity using the sequence of last year.
When epoch = 100, one of predictions is shown:

change the number of epoch is the same.

why the pattern of every day’s prediction is the same. Is there anything wrong?


It seems your model is not learning the right pattern.
I would recommend to select a small subset of the data (e.g. just 10 samples) and try to overfit this dataset.
Once your model successfully predicts the target, you could then scale up the use case.
If your model is unable to do so, there might be a bug in the code or the model architecture is not suitable for this task.

If you view your output as global_bias + phase_adjustment(t) + timeseries_specific_adjustment(t,x), conclusion would be that the last component was not learned. If you start your rnn with zero context, this can mean that your timeseries have no distinguishing features when fed step-by-step, to have non-zero timeseries specific bias (encoded in hidden state). In other cases such features may be missed (try GRU and slower training).

Thank You, Alex. If the timeseries_specific_adjustment was not learned, is there any techniques to improve it? I have tried slower training as you said.

Thank you, ptrblck. I tried 30 samples, the prediction is almost the same. Although it changed a little, the pattern of each day is the same. That is the result:

What inputs is your rnn receiving?

The temperature of last year. seq_len = 24 * 365. The output is the electricity of next month, 24 * 30.

Well, you should at least feed it things like month, day of week, hour of day (one-hot encoding is the simplest way). But I don’t think you can do much better than your second plot.

In general, that’s not a good task for neural networks. Usual forecasting methods decompose seasonal data (nb: explicitly defined) and use relatively simple formulas to forecast the remainder stepwise. And there is not much else you can do, that would generalize to unseen data.

Use of RNNs may be justified when many “features” with complex interactions are present, but in your case deseasoned fluctuations are likely “unexplainable”.

Maybe you should try something like Prophet. For more basic ideas, you may check online book