Reframing Forecasting as Supervised Learning
Classical time-series models treat a series as one continuous object to model directly; machine learning instead slices it into a table of past-windows-predicting-future-values, turning forecasting into an ordinary supervised learning problem — with real tradeoffs from making that switch.
Prerequisites: The Supervised Learning Framework, Lag and Rolling-Window Features
Classical forecasting models — ARIMA, exponential smoothing — treat a time series as a single mathematical object with structure (trend, seasonality, autocorrelation) baked into the model's equations. Machine learning models like gradient-boosted trees or random forests don't work that way; they take a table of rows and columns and learn a mapping from inputs to an output. To use one of these models on a time series at all, the series first has to be reshaped into that table. That reshaping — turning one long sequence into many rows of "past window → next value" — is what it means to reframe forecasting as supervised learning, and the choices made during that reshaping matter as much as the choice of model.
The sliding window
The standard technique is a sliding window: pick a lookback length , and for every point in the series, build one training row whose features are the most recent values before — — and whose label is the value at itself, . Slide this window forward one step at a time across the whole series, and a single sequence of observations becomes roughly rows of an ordinary supervised-learning table. Any standard regression model — a random forest, a boosted tree ensemble, even plain linear regression — can now be trained on it exactly as if the rows were independent, unrelated data points, even though they obviously are not.
Worked example: windowing a ten-point series
Take the small daily-close series 100, 102, 101, 104, 106, 105, 108, 110, 109, 112, and use a lookback of . The sliding window produces these rows:
| 100 | 102 | 101 | 104 |
| 102 | 101 | 104 | 106 |
| 101 | 104 | 106 | 105 |
| 104 | 106 | 105 | 108 |
| 106 | 105 | 108 | 110 |
| 105 | 108 | 110 | 109 |
| 108 | 110 | 109 | 112 |
Ten raw observations became seven training rows. A model trained on this table learns to map "the last three prices" to "the next price," using exactly the same machinery — same loss function, same tree-splitting logic — it would use on any other regression problem, with no special-cased time-series logic anywhere inside the model itself.
Sliding-window reframing lets any off-the-shelf regression model be applied to a time series, but it also destroys the model's awareness that rows are correlated and ordered — which is why cross-validation, feature construction, and label construction all need time-series-specific care even after the reshaping is done (see lag features and leakage boundaries).
What this means in practice
This reframing is what makes gradient-boosted trees viable for forecasting at all, and it's why they can outperform classical models when there are many exogenous features (macro indicators, cross-sectional signals from other assets) that don't fit naturally into an ARIMA-style equation — a tree model can just take them as extra columns in the same table. The tradeoff is that the model has no built-in notion of "time" beyond whatever lag features are explicitly constructed; if a useful pattern lives outside the chosen lookback window, or depends on the order of values within the window in a way tree splits can't easily represent, the model simply cannot see it, whereas a classical model with an explicit seasonal term captures that structure by construction. A second consequence is more subtle: because the rows generated by a sliding window from the same series are highly overlapping and correlated, a naive random train/test split (rather than a strict time-based split) leaks information from adjacent, nearly-identical windows across the split boundary — this is one of the most common sources of inflated backtest performance in ML-based forecasting.
Practice
- Using the ten-point series above with a lookback of instead of 3, write out the resulting training table.
- Explain why randomly shuffling the rows of a sliding-window table before splitting into train and test sets produces an overly optimistic backtest, even though each row is technically a valid input-output pair.
The common mistake is treating the reshaped table as if its rows were independent, identically distributed samples — the standard assumption behind ordinary cross-validation — when in fact adjacent rows share almost all of their feature values by construction. Any evaluation scheme that doesn't respect time order when splitting a sliding-window table will overstate how well the model generalizes to genuinely new data.
Related concepts
Practice in interviews
Further reading
- Bontempi et al., Machine Learning Strategies for Time Series Forecasting (2013)