Lag and calendar features

Turning forecasting into a supervised problem means building features from the past: lagged values, rolling statistics, calendar components (day, month, public holiday). A tabular model such as gradient boosting can then predict. All features must be known at forecast time.

Example

df['lag_1'] = df['y'].shift(1)
df['moy_7'] = df['y'].shift(1).rolling(7).mean()

Related concepts

The whole glossary