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

enter image description here

I use Keras.sequential.LSTM library.

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

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.

| improve this answer | |
  • $\begingroup$ Could you find any solution? $\endgroup$ – user145959 Mar 2 '19 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.