Part 2: Implementation - Building a Retail Backtesting Framework in Python on the M5 Walmart Data
Part 1 introduced a three-metric scorecard - WMAPE, Total Bias, and Active Seller Bias- for judging whether a SKU_level forecast puts the units in the right place. Here, we turn the framework into a reusable,leakage-safe backtesting framework in Python, using the public M5 Forecasting dataset from Walmart.
Why M5, and how does it map to allocation problems?
M5 has ~30,400 item-store sales (3049 products, 10 stores in California, Texas, and Wisconsin, 3 categories, 7 departments) covering 1,941 days. It’s intermittent and long-tailed, with plenty of zeros and late launches, which is exactly the setting where allocation errors hide.
Scorecard Concept
In a sizing/allocation context
M5 equivalent used here
item_id X store_id
Backtest Window
6 weeks, summed
6 Walmart weeks ( wm, yr, wk), summer
Product Age
New vs Existing products
New if first sale in the store is < 26 weeks before the forecast origin
Regional group
Differentiation at...
Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE