Projects / CPI Transformer Risk Dashboard

CPI Transformer Risk Dashboard

An end-to-end inflation-forecasting system: a PyTorch Transformer encoder predicts year-over-year CPI, a classical ARIMA model provides an honest baseline, and a SHAP-powered Streamlit dashboard surfaces the macro drivers behind every forecast.


Problem

Inflation surprises move rates, equities, and credit spreads, yet most accurate forecasts are opaque. This project pairs a strong sequence model with transparent attribution, so a risk team can see both the number and the macro forces driving it.

Methods

  • Transformer encoder (multi-head self-attention) over a 24-month window of macro features, predicting next-month CPI YoY.
  • Rolling SARIMAX(1,1,1) baseline on the CPI YoY series for a fair, univariate benchmark.
  • Gradient-based SHAP attribution to rank the top macro drivers.
  • Strict temporal train/validation/test split (70/15/15) with no look-ahead leakage.

Outputs

  • Point forecasts of CPI YoY with a head-to-head RMSE comparison.
  • Driver-attribution bar chart (top-5 macro features).
  • Forecast-vs-actual timeline on the held-out test set.
  • Reproducible artifacts (metrics.json, timeline.csv, top_drivers.json, model weights).

Stack

PyTorch · statsmodels (SARIMAX) · SHAP · scikit-learn · pandas/NumPy · Streamlit.