liveBook · Manning

Lag

As explained in Machine Learning System Design

A feature or time-series value obtained from an earlier time point relative to the prediction time.

A lag is an earlier value of a time-series feature used relative to the prediction time. Shifting values backward creates features that let a model use past observations when making a prediction. section 11.1.2

Retail demand

To forecast an item’s sales for September 8, a simple baseline uses its actual sales from September 1. Going back a full week rather than one day accounts for weekly seasonality and possible delays in data availability. A linear-model baseline can instead use multiple lags alongside rolling aggregates. section 8.6.1

More lags can help a model capture more complex patterns and seasonality, but they also make it easier to overfit. Compare a short history, such as the previous three days, with a longer one, such as the previous 30 days, using a model-wise learning curve to choose an appropriate number. section 9.4.1

Lags are one way to reuse past data. Window aggregates, such as means, maxima, or minima, offer another way to summarize a history rather than supplying each earlier value separately. section 11.1.2

How Machine Learning System Design covers it

How deep it goes
Defines lag transformations and discusses selecting their number with a model-wise learning curve, without implementation details.
Examples
Uses a previous-week retail sales baseline and a linear model with multiple lags and rolling aggregates.
What you can do after
Evaluate lag counts against model complexity and overfitting using a model-wise learning curve.
How it connects
Connects lags to seasonality, rolling-window aggregation, overfitting, and learning curves.

Also explained in

Compare how 5 books explain lag →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning System Design. The section links point to the parts of the book it draws on.