I'm studying machine learning (e.i. time series analysis). I encountered an Azure tutorial, Retail Forecasting.


Here, they introduce new features called "lag", which I don't understand what it means. In 3.4, they said "The module selects the best lag of this index based on maximum correlation." What does it mean? Could you please let me know some references to learn background knowledge?

  • $\begingroup$ When you have a variable which is dependent on time $x_t$, the first lag of $x$ is $x_{t-1}. So you look back in time. The idea is that in many cases, previous outcomes are dependent on "yesterdays" outcome. E.g. todays temperature is correlated to yesterdays temperature. $\endgroup$
    – Peter
    Apr 17, 2020 at 11:55
  • $\begingroup$ Thank you for your response. Could you also explain what "the best lag" means? $\endgroup$
    – hgshin
    Apr 17, 2020 at 12:05
  • $\begingroup$ You can choose lags $x_{t-1}$,$x_{t-2}$ up to $x_{t-n}$ and you don't know ex ante what lag(s) to choose. The best lag cold be ont with most power to explain some outcome. $\endgroup$
    – Peter
    Apr 17, 2020 at 12:11
  • $\begingroup$ We can now "automate" lag feature creation in python with the LagFeatures transformer from feature-engine: feature-engine.readthedocs.io/en/latest/user_guide/timeseries/… $\endgroup$
    – Sole G
    Nov 17, 2022 at 15:40

1 Answer 1


Lag features are target values from previous periods.

For example, if you would like to forecast the sales of a retail outlet in period $t$ you can use the sales of the previous month $t-1$ as a feature. That would be a lag of 1 and you could say it models some kind of momentum. But you could also apply a lag of 12 to model the sales of the same month a year ago (since retail sales are often seasonal depending on the format, category and SKU). Accordingly, it depends on the dataset which lags work best and looking at correlation is one way to select the lag values.

Have a look at this blog post for a simple explanation of lag features.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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