Forecasting with XGBoost & Chronos
Predictive modeling on macroeconomic time-series data.
What you'll learn
- 1Days 61–63Supervised learning theory, tree-based models, and univariate forecasting.
By the end: Students can frame macro forecasting as a supervised-learning problem without leaking the future. They build a **rolling-origin evaluation harness** (pseudo out-of-sample), understand decision trees, random forests and gradient boosting (XGBoost) from the ground up, and run an honest **univariate horse race** for Canadian CPI inflation at several horizons. Every model is judged against naive and autoregressive benchmarks, with statistical tests and calibrated prediction intervals.
- 2Days 64–67Hyperparameter tuning, SHAP explainability, and zero-shot forecasting with Chronos.
By the end: Students can tune XGBoost **without contaminating the test period**, explain every forecast with **SHAP values** (globally, for a single forecast, and as a decomposition over time), and evaluate a pretrained **time-series foundation model (Chronos)** zero-shot in the same harness. They finish with probabilistic scores and a combination forecast, and choose, with evidence, which models to carry into the Day 68–70 CPI and GDP forecasting system.
- 3Days 68–70Forecasting Canadian CPI and real GDP growth with features engineered earlier.
By the end: - **Day 68.** Students forecast **CPI inflation** with **multivariate features** drawn from the marts built in Modules 2–4 (rates, spreads, FX, oil, labour market, core and breadth measures), respecting each indicator's **publication lag**. **Day 69.** They **nowcast and forecast real GDP growth** from monthly indicators with a "ragged edge" and handle the COVID outliers honestly. **Day 70.** They put the forecasting system **into production** inside the Prefect pipeline: published forecasts with metadata, dbt marts that track **live accuracy**, GX checks on forecasts, monitoring for out-of-range inputs, a model card, and a forecast dashboard.
Tools
The ten days
Before you start: module setup and project structure
Audience: MSc Economics students who completed Parts I–II (Days 1–60)
Environment: GitHub Codespaces · a new .venv-ml · the dbt marts exported to data/marts/*.parquet
Time per day: ~2.5 hours (including breaks and exercises)
Goal by end of Day 63: Students can frame macro forecasting as a supervised-learning problem without leaking the future. They build a rolling-origin evaluation harness (pseudo out-of-sample), understand decision trees, random forests and gradient boosting (XGBoost) from the ground up, and run an honest univariate horse race for Canadian CPI inflation at several horizons. Every model is judged against naive and autoregressive benchmarks, with statistical tests and calibrated prediction intervals.
Part III begins: why the platform matters for modelling
Parts I–II built a pipeline that produces clean, tested, documented, timely data. Forecasting is where that investment pays off, because forecasting is unforgiving of data problems:
| Data problem | What it does to a forecast |
|---|---|
| a gap in the series (Day 49) | lags point to the wrong month; features silently shift |
| a unit error (Day 41) | the model learns from nonsense; error metrics explode |
| using revised data as if it were known at the time (Day 27) | evaluation looks better than real-world performance |
| features computed with future information | leakage: brilliant backtests, useless forecasts |
You'll meet that last problem constantly this module. Avoiding it is the single most important skill in applied forecasting.
The plan for Module 7
| Days | Focus |
|---|---|
| 61–63 | supervised learning theory, honest evaluation, trees and boosting, univariate forecasts |
| 64–67 | hyperparameter tuning, SHAP explainability, zero-shot forecasting with Chronos |
| 68–70 | forecasting Canadian CPI and real GDP growth with the features engineered in Modules 2–4 |
Target structure (by end of Day 63)
macro-data-course/
├── .venv-ml/ ← NEW: modelling environment
├── macro_dbt/models/marts/ml/
│ └── ml_cpi_monthly.sql ← NEW: a mart for modelling (exported to Parquet)
├── forecasting/ ← NEW: reusable modelling code
│ ├── __init__.py
│ ├── data.py ← loading marts
│ ├── features.py ← leakage-safe feature construction
│ ├── evaluate.py ← rolling-origin harness, metrics, Diebold–Mariano
│ └── models.py ← benchmarks and model factories
├── notebooks/ ← exploration (day61.ipynb, …)
└── data/forecasts/ ← results (not committed)