I am using this code here: https://machinelearningmastery.com/time-series-prediction-lstm-recurrent-neural-networks-python-keras/ and more specifically the python code under the (1st) paragraph "LSTM Network for Regression". I am testing it with a simple .csv file where I have the 1st column (X values) and the 2nd column (Y values). I get extremely good results. My concern is: Do you something strange on the code of the above link?

  • $\begingroup$ I mean how can I face so good accuracy? Which are the python commands (from the above code) more responsible for that? $\endgroup$ Oct 14, 2022 at 13:20

1 Answer 1


It is basically because of the simplicity of the data points and nothing strange about the code. If you look at the plot in the blog, you can basically replicate those observations with a simple mathematical function. Additionally, the data points are just in two dimensions which makes the problem even simpler. This data basically has a trend that is linear (of the form mx + c) and a sinusoidal variation with some local low-frequency noise.

It is generally understood and known that for any simple dataset where the patterns are very obvious to the human eye, any machine learning algorithm will easily learn the pattern. If it can also be expressed mathematically fairly in a simple form, then any ML model will learn to generalize it. You can repeat that exercise by replacing the same data with a simple sinusoid and will see similar results.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .