A UK retail chain operating 120 stores was carrying 4.2 million GBP in excess inventory at any given time -- slow-moving stock occupying warehouse capacity, generating markdown costs, and written off at a loss. Demand planning was done in spreadsheets: category managers used last year's actuals plus a gut-feel seasonal adjustment. Baseline MAPE (Mean Absolute Percentage Error) was 27%. Replacing this with an ML forecasting model brought the error to 8.3% and reduced excess stock by 34%.
Why Spreadsheet Demand Planning Breaks at Scale
A human analyst can maintain mental models for perhaps 50-200 product-location combinations. At 120 stores multiplied by thousands of SKUs, the combinations exceed 200,000. Category managers compensate with blanket adjustments -- 'increase summer SKUs by 15%' -- that ignore heterogeneity across product types, store demographics, and local events.
Specific failure modes: over-ordering trend items whose demand peaked early; static annual safety stock that ignored volatility changes; external signals (school holidays, local events, weather) not systematically incorporated; forecasts at category level that masked winner/loser dynamics within the category.
XGBoost + Prophet Architecture
The system combines XGBoost for feature-based prediction with Facebook Prophet for trend and seasonality decomposition. Feature engineering enriches each SKU x store x week observation with: 8/13/26/52-week rolling sales averages; price and promotion flags; category-level growth trend; seasonal signals including UK bank holidays and school holiday flags by postcode district; store attributes (size tier, location type, regional affluence); Met Office weather data; and current stock weeks-of-cover.
Prophet decomposes each time series into trend and seasonality components added as features to XGBoost. The model trains on 3 years of weekly sales data (approximately 18 million rows) and re-trains weekly via Airflow DAG in 4.5 hours.
Dynamic Safety Stock
The forecast alone does not solve the inventory problem. Dynamic safety stock is the other critical component. The model outputs a prediction interval alongside the point forecast. Items with higher uncertainty (high coefficient of variation of residuals) get proportionally larger safety stock buffers. Lead time variability from supplier history is incorporated. Service level targets are configurable per category (98% for core basics, 90% for trend items where overstocking risk outweighs stockout risk).
The system generates weekly reorder recommendations per SKU per store. Buyers now review exception cases rather than making decisions for every SKU. Their time on replenishment fell from 60% to 20% of the working week.
Results After 12 Months
Demand forecast MAPE: 27% to 8.3% (-69% error). Excess inventory: 4.2 million GBP to 2.8 million GBP (-34%). Write-offs as percentage of revenue: 2.4% to 1.4% (-42%). Stockouts for top 500 SKUs: 8.3% to 3.1% (-63%). Buyer time on replenishment: 60% to 20% of working week.
The transition challenge was not technical but human: buyers who had planned by intuition initially overrode model recommendations heavily in the first 8 weeks. The team ran a 10-week parallel track -- showing buyers the model's recommendation alongside their own decision and tracking outcomes -- before switching to model-led replenishment. For UK retailers at 20+ stores and 1,000+ SKUs, the data required -- historical sales by SKU by location -- is almost always already in the existing ERP or POS system.
Related Codeworth Services
Need Help with Implementation?
The Codeworth team is ready to implement these ideas in your project. Free consultation.
Discuss the ProjectCo-founder of Codeworth with 7 years of UK fintech ML experience. Specialises in credit scoring with FCA compliance, ensemble methods including XGBoost and LightGBM, and ML experiment management via Python and MLflow. Has built production systems for credit decisioning processing millions of applications annually under FCA oversight. Holds deep knowledge of FCA model explainability requirements and Consumer Duty documentation standards.