Why my results have time delay when I use LSTM?

I am trying to fit and test LSTM on a numeric series(like stock prices). But it seems that I always get a lag in predicted graph(Blue) with respect to real graph(red). Does anyone know why this happened? (I searched and realized this is a problem for others too).

I use Keras.sequential.LSTM library.

Topic lstm difference

Category Data Science


I've had similar results when working with time series data. My conclusion was that the model does not learn any real pattern, except that the next value is pretty close to the previous one (or a smoothing of previous ones) + some noise.

This can be easily verified, if you feed your model's predictions recursively into the model to further predict the future (multi-step ahead forecasting based on the model's predictions). In the above mentioned case, your predictions will explode exponentially pretty quickly.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.