Forecasting as Supervised Learning
P7.forecasting.04 · Audience: guest, it-ml, language-pro · Prerequisites: Baselines You Must Beat, Supervised Learning Algorithms
Everything so far has been purpose-built forecasting machinery — smoothing dials and ARIMA dials. This module shows a different move entirely: reshape the series so that the whole Traditional ML toolbox from P5 applies to it. One table transformation turns "forecast the future" into "predict a target column", and suddenly every regressor you already know is a forecaster. The trick is powerful, widely used — and it re-arms the exact leakage trap this pillar opened with.
Slide a window along the series and stack what it sees. Each position contributes one row: the previous values become feature columns — lag features — and the next value becomes the target. Take the tiny series [10, 12, 13, 15, 14, 16] with two lags:
| y(t−2) | y(t−1) | target y(t) |
|---|---|---|
| 10 | 12 | 13 |
| 12 | 13 | 15 |
| 13 | 15 | 14 |
| 15 | 14 | 16 |
That is the entire trick. The result looks exactly like the tabular data of the Traditional ML pillar: feature columns, a numeric target, one row per example. Forecasting has become regression on lags — predict y(t) from y(t−1) and y(t−2). To forecast tomorrow, build the feature row from the latest observed values and ask the model for its prediction.
🗣️ From a linguist's perspective: You have seen this window before
Ask the mentor about this module
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
Try it yourself
A scratch console for this page's ideas — ungraded, nothing you run here is recorded.
Scratch console
A scratch console with the scientific stack (pandas, numpy, scikit-learn). Runs on the server — no network, resource-limited and measured.
Output appears here.
Where next?
Later in Forecasting
Go up a level