XGBoost for Supply Chain Forecasting

Explore how gradient-boosted trees compare against ETS and Seasonal Naive across 7 retail departments. Switch models, inspect features, and see where tuning actually moves the needle.

Forecast vs Actuals

Actuals (test) XGBoost ETS SNAIVE Training context

MASE by Department & Model

MASE < 1 beats seasonal naive — most departments clear that bar; department 1_3 is an outlier driven by a mid-test spike. Lower is better; best per department highlighted in blue.

DepartmentXGBoostETSSNAIVE
Test window: last 12 weeks of data. MASE denominator = in-sample seasonal-naive MAE (period = 52). Source: generated by Bravo-Zero-R R script.

What the Chart Tells Us

XGBoost Feature Importance — Top 15

Lag features Rolling features Calendar / holiday

What These Features Mean

Hyperparameter Grid

Average MASE for each (tree_depth × learn_rate) combination. Green = better, red = worse. All 9 cells are measured values — each is the mean MASE across 7 departments when the model was refit at that exact depth × learn_rate combination. Green = better.

The Quiet Lesson

Data Footnote

Dataset: timetk::walmart_sales_weekly, 7 departments at a single Walmart store × 143 weekly observations (Feb 2010 – Oct 2012). XGBoost trained as a single global model across all departments (one-hot id), spec configuration trees=500, min_n=10, tree_depth=6, learn_rate=0.01, sample_size=0.8 via the tidymodels interface. Baselines: SNAIVE (m = 52) and ETS via forecast::stlf() (STL + ETS, used instead of raw forecast::ets() which caps seasonal period at 24). Horizon: 12 weeks (last 12 observations held out; split date 2012-08-10). MASE is computed against the in-sample seasonal-naive MAE at m = 52. The 3×3 hyperparameter grid above is measured — each cell is the mean MASE across the 7 departments when the model was refit at that depth × learning-rate combination.