# 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.

• It would be easier to understand your problem and help you if you can provide the code too! – naive Feb 25 '19 at 14:05

## 1 Answer

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.

• Could you find any solution? – user145959 Mar 2 '19 at 6:29