Machine Learning for Forecasting — Features Over Time

When classical methods aren't enough — many related series, rich external drivers, complex nonlinear patterns — you can bring the full machine-learning toolkit to forecasting. But you can't just feed a time series to a standard model; you have to reframe forecasting as a supervised learning problem through the right features. This post is about that reframing, where ML genuinely helps, and the time-specific traps that make it easy to get wrong.

Posts 3–4 covered classical methods and honest evaluation. This post bridges to the machine learning foundations: using regression, gradient-boosted trees, and the like for forecasting. The key move is turning a time series into a feature matrix — and doing it without leaking the future (post 4), which is where most ML-forecasting attempts quietly fail.

Reframing forecasting as supervised learning

A standard ML model (ML series) maps a feature vector to a target. A time series is just a sequence of values. To use ML, you turn the series into a supervised dataset: each row’s target is the value to forecast, and its features are things known before that point. The central technique is lag features — using past values as inputs:

Once the series is a feature matrix, you train a standard model — very often gradient-boosted trees (ML series, post 4), which excel on this kind of tabular, engineered-feature data and are a dominant practical choice for ML forecasting. Forecasting becomes feature engineering plus a tabular model, which is a powerful and flexible reframing.

Where ML beats classical methods — and where it doesn’t

ML forecasting genuinely shines in specific situations, and it’s important to know them rather than reaching for ML reflexively (post 3’s warning):

But the honest counterbalance (post 3): for a single series with limited data and clear trend/seasonality, classical methods (ETS, ARIMA) are often better, simpler, and more robust than ML — and the M-competitions showed ML doesn’t reliably beat classical on typical series. So the decision rule: reach for ML when you have many series, rich drivers, complex patterns, or abundant data; stick with classical for single, short, well-behaved series. And always benchmark ML against classical and naive baselines (post 4) — ML forecasting that can’t beat Holt-Winters or seasonal-naive isn’t worth its added complexity, and this happens more often than ML enthusiasts expect.

The time-specific traps

ML forecasting has failure modes beyond ordinary ML, all stemming from the time dimension, and they’re where most attempts go wrong:

Handled with these in mind, ML is a powerful forecasting tool for the right problems — reframe the series into leakage-free lag/rolling/calendar/driver features, use gradient-boosted trees (or similar), benchmark ruthlessly against classical and naive baselines, backtest properly, and watch the trend-extrapolation trap. Used reflexively or carelessly, it’s slower and worse than a classical model while carrying hidden leakage. The skill is knowing it’s a fit for specific situations (many series, rich drivers, complex patterns, big data), not a universal upgrade.

The throughline: to forecast with ML you reframe the series as a supervised dataset via features known before each point — lag features (past values — encoding autocorrelation), rolling-window statistics (recent trend/volatility), date/time features (encoding seasonality), and external drivers (price/promos/weather — the big advantage classical univariate methods lack) — then train a tabular model, very often gradient-boosted trees. ML beats classical with many related series (a single global model sharing strength across them), rich drivers, complex nonlinear patterns, and abundant data — but for single, short, well-behaved series classical wins, so benchmark ruthlessly against classical and naive baselines (post 4). The time-specific traps: feature leakage (every feature must be available at forecast time — the dominant failure, even easier with engineered features), awkward multi-step forecasting (recursive error-compounding vs per-horizon models), mandatory backtesting (no random CV), and trees can’t extrapolate trend (remove the trend first or they under-forecast).

Key takeaways

Further reading

Sources & References