Time Series Forecasting — Classical, ML Features & Deep Sequences
Tell a truly temporal problem from a table that happens to have a timestamp. Wrong choice means leakage, optimistic MAPE, and models that die after a holiday. Map classical ARIMA/ETS/Prophet, trees on lags, and deep sequences — with walk-forward validation. Prediction is not a counterfactual.
- 1Gist
- 2Maps
- 3Q&A
- 4Sandbox
Voice readout needs Web Speech Synthesis in this browser.
Sales next 14 days vs ‘did the launch move sales?’
Prefer
Forecast family + walk-forward + as-of features
Predict Y at t+h given information available at t. Keep a seasonal naive on the board. Escalate only when exog or multi-series capacity justifies it.
- Shuffle test: if order does not matter, you wanted tabular methods.
- Known-ahead calendar / prices are legal; future weather actuals are not.
- LLM text is not a calibrated numeric engine.
Alternative
Random K-fold plus a deep sequence, or calling MAPE a launch effect
Future rows leak into training. A dashboard that ‘looks accurate’ can still be the wrong estimand after a policy shock.
- Prophet is not magic SOTA.
- Identification of a shock is a different cluster.
- Foundation models need data and ops you may not have.
Overview
Interviewers probe whether you can tell a truly temporal problem from a cross-sectional table that happens to have a timestamp. Wrong choice → leakage, optimistic MAPE, and models that die after a holiday.
This page maps classical, trees on lags, and deep sequences. It does not teach counterfactual designs. Those live on causal time series: forecasting answers “what next under the old policy”; a launch effect is not a forecast.
Is it truly temporal?
- Autocorrelation / partial autocorrelation significant at operational lags.
- Seasonality and trend visible after decomposition.
- Shuffling time order destroys predictive skill.
- Cross-sectional with a time column: each row is independent given features — use tabular methods and time-aware splits only if deployment is temporal.
Stationarity (practical view)
- Classical ARIMA wants stable mean / variance (or differenced / seasonally differenced series).
- Trees / deep nets do not require classical stationarity but still suffer from drift and regime change.
- Always plot; difference or detrend when using ARIMA; for ML, include time features carefully so you do not leak future calendars incorrectly.
Family map
- ARIMA / SARIMA — short–medium univariate, interpretable coeffs, strong baseline.
- ETS / exponential smoothing — seasonality + trend with few knobs.
- Prophet-style — analyst-friendly holidays / seasonality; not magic SOTA.
- Trees on lags + rolling stats + calendar — many exogenous drivers; intermittent demand often OK.
- LSTM / TCN / TFT / foundation TS — long horizons, rich covariates, multi-series; higher ops cost.
- LLM numeric forecast — niche; prefer for narratives or constrained APIs, not as the default engine. Structured Outputs is an interface, not a calibrated forecast.
Leakage via future covariates
- Known-in-advance: calendar, planned price, scheduled marketing — OK if truly known at forecast time.
- Unknown-at-inference: future weather actuals, same-day sales of related SKUs — leakage if used as if known.
- Document as-of times; build features only from data available at the prediction timestamp.
Train / val: walk-forward
- Never random row splits on temporal data.
- Expanding or sliding windows; evaluate each origin; average metrics.
- Purge gaps when labels depend on future windows (e.g. 7-day-ahead label).
Pros / cons
- Classical: strong baselines, explainable; weak with many exog / nonlinearities.
- Trees + lags: great with exog; need careful lag design; weaker pure long-horizon memory vs seq models.
- Deep / foundation: capacity for complex dynamics; data-hungry; harder to operate and explain.
Architecture (diagnose, baseline, escalate)
Decisions
- 1
1 ACF / seasonality / shuffle
- next2 Truly temporal?
- ?
2 Truly temporal?
- no3 Tabular + time-aware split
- yes3 Naive / ETS / ARIMA
- 3
3 Tabular + time-aware split
- 4
3 Naive / ETS / ARIMA
- next4 Many known-ahead exog?
- next6 Walk-forward plus audit
- ?
4 Many known-ahead exog?
- yes5 Trees on lags + calendar
- long multi-series5 Seq / TFT / foundation
- 6
5 Trees on lags + calendar
- next6 Walk-forward plus audit
- 7
5 Seq / TFT / foundation
- next6 Walk-forward plus audit
- 8
6 Walk-forward plus audit
Lesson map
Time Series Forecasting — Classical, ML Features & Deep Sequences
Tell a truly temporal problem from a table that happens to have a timestamp. Wrong choice means leakage, optimistic MAPE, and models that die after a holiday. Map classical ARIMA/ETS/Prophet, trees on lags, and deep sequences — with walk-forward validation. Prediction is not a counterfactual.
Architecture. Architecture
Select a node to see why it exists, or an edge to see the protocol, direction, effect, and consequence.
Mermaid export
flowchart TB dev["Scientist"] split["Origin"] model["Family"] met["Metric"] dev -->|Train on 1 to t| split split -->|Fit as-of t| model model -->|Score t to t| met dev -->|Train on 1 to t| split split -->|Refit as-of new| model model -->|Score next| met
Walk-forward origins (sequence)
Lifelines stay inside the card. Each origin trains only on the past.
Sequence
- 1
Scientist
1 Expanding window
- 2
Scientist → Origin
Train on 1 to t
- 3
Origin → Family
Fit as-of t
- 4
Family → Metric
Score t to t plus h
- 5
Scientist
2 Next origin
- 6
Scientist → Origin
Train on 1 to t plus h
- 7
Origin → Family
Refit as-of new t
- 8
Family → Metric
Score next horizon
Sandbox: lags + origins (Python)
Press Run. Snippets must be self-contained — no network, files, or native modules.
Same helpers (TypeScript)
Press Run. Snippets must be self-contained — no network, files, or native modules.
Pitfalls
You forecast tomorrow’s demand at 6am. Marketing has a planned promo flag. Weather actuals exist for tomorrow in the warehouse. Which feature is legal at 6am, which is leakage, and how would walk-forward catch the second if you cheated?
Interview Q&A
Why not random K-fold on sales data?
Answer
Future rows leak into training folds; metrics become optimistic. Use walk-forward with as-of-correct features.
ARIMA vs LightGBM with lags?
Answer
ARIMA for short univariate with clear dynamics; LightGBM when many exog and nonlinear effects dominate. Always keep a seasonal naive baseline.
What is a future covariate vs a lag?
Answer
A lag uses past target / features only. A future covariate is a value at or after the forecast origin — allowed only if known in advance at inference.
When do deep sequence models pay off?
Answer
Large multi-series panels, long horizons, rich known covariates, and team capacity to productionize — not for a 200-point single series.
Timestamp column but shuffle does not hurt — now what?
Answer
You probably have a cross-section. Use tabular families from the hub with a time-aware split only if production is temporal.
Prophet ate my residuals — ship it?
Answer
Not until you beat seasonal naive, inspect leftover seasonality, and walk-forward. Prophet is an analyst-friendly baseline, not a trophy.
Intermittent demand (many zeros)?
Answer
Croston / TSB-style classical methods, or trees on lags with a zero-aware metric. MAPE explodes on zeros — prefer MAE or a scaled error. Depth: playbook.
LLM as the forecast engine?
Answer
Niche for narratives or constrained API wrappers around a numeric model. Horizons still belong to classical / ML / deep TS. Structured output is an interface, not calibration.
Forecast vs ‘the mandate changed infections’?
Answer
Forecast = expected Y at t+h given history. A shock’s effect is a counterfactual under a different policy. Hand off to causal time series; do not re-teach those designs here.
How far can trees-on-lags see?
Answer
As far as you stacked lag / rolling / calendar features. They do not magically hold a 52-week memory the way a sequence model can — and they still need walk-forward.
Go Deeper
- Forecasting: Principles and Practice
- sklearn TimeSeriesSplit
- Prophet docs
- StatsForecast
- Temporal Fusion Transformers (arXiv)
- Sibling (counterfactuals, not forecasts): causal time series
- Next: Algorithm selection playbook