EliconStart a project →
← ALL WORK

CASE 13

12 weeks

ML Demand Forecasting for a Retailer

Fewer stockouts, less overstock, fewer spreadsheets.

  • Python
  • FastAPI
  • Prophet/PyTorch
  • Postgres
  • dbt
Sector
Multi-category retail
Scale
Thousands of SKUs, multiple warehouses
Before
Weekly spreadsheet + judgement
Engagement
Fixed scope, 12 weeks
Delivery
Suggestions inside the WMS

A multi-category retailer forecasted demand by pasting last year's sales beside a gut-feel column. We built a SKU-level forecasting pipeline with hierarchical reconciliation, delivered suggestions into the system where purchase orders actually get written, and published accuracy back-tests so the category team could see exactly when to trust it.

THE PROBLEM

What was going wrong.

A category manager forecasted demand weekly by pasting last year's sales next to 'gut feel' columns. Peaks meant stockouts; lulls meant writedowns.

The manual process worked acceptably for top sellers, where the manager's intuition was genuinely good, and badly for the long tail, which was too large to think about SKU by SKU.

Promotions and seasonality were handled by memory. If the person who ran last year's campaign had left, the demand spike was a surprise for the second time.

Category totals and SKU-level plans never agreed, so finance planned against one number and the warehouse ordered against another.

CONSTRAINTS WE WORKED UNDER

  • ·Forecasts must land where purchase orders are written. A dashboard nobody opens changes no orders.
  • ·Category, subcategory and SKU forecasts have to reconcile — inconsistent hierarchies were an existing source of distrust.
  • ·The category team had to be able to see when the model was wrong, or they would not use it when it was right.
  • ·Three years of history with known gaps around a system migration and a pandemic period that must not be treated as ordinary demand.

WHAT WE DID

The short version.

  1. 01

    Built a SKU-level forecasting pipeline (hierarchical reconciliation so category totals always match).

  2. 02

    Mixed a statistical baseline with a trained neural model for the long-tail SKUs.

  3. 03

    Integrated with the warehouse management system so reorder suggestions land where purchase orders actually get written.

  4. 04

    Weekly back-tests and accuracy dashboards so the category team sees exactly when the model helped and when it didn't.

ARCHITECTURE

How it's built.

01

Feature pipeline

dbt models over sales, promotions, price changes, stockout periods and calendar effects. Critically, stockouts are masked rather than read as zero demand — otherwise the model learns to under-forecast exactly the SKUs that ran out.

02

Two-model ensemble

A statistical baseline handles seasonal, well-behaved SKUs; a trained neural model handles the intermittent long tail where classical methods degrade. Selection is per SKU, decided by back-tested accuracy rather than by preference.

03

Hierarchical reconciliation

SKU forecasts reconciled upward so subcategory and category totals sum correctly. This removed the recurring argument between finance and the warehouse about which number was real.

04

Delivery into the WMS

Reorder suggestions written into the warehouse system with the forecast, the confidence interval and the reasoning attached. The buyer accepts, edits or rejects in the tool they already use, and every decision is captured.

05

Back-test dashboard

Weekly rolling-origin back-tests reporting accuracy by category, by SKU tier and against the previous manual process. Published whether the numbers flatter the model or not.

KEY DECISIONS

What we chose, and what it cost.

Masked stockout periods instead of treating them as demand

WHY

Zero sales during a stockout is censored data, not low demand. Ignoring this is the most common way retail forecasting quietly fails.

TRADE-OFF

Less usable history for the SKUs that stocked out most, which is exactly where more data would have helped. Correct anyway — biased data is worse than less data.

Excluded the pandemic period rather than modelling it

WHY

Two years of anomalous behaviour would have taught the model patterns that will not recur. Attempting to model it would have burned weeks for negative value.

TRADE-OFF

A gap in history and weaker long-horizon seasonality for some categories. We documented the choice so nobody rediscovers it as a bug.

Suggestions in the WMS, not a forecasting dashboard

WHY

Adoption is a delivery problem more than a modelling one. A better forecast that lives somewhere buyers do not go improves nothing.

TRADE-OFF

WMS integration was fiddlier than a standalone app and added roughly two weeks. It is the reason the model changed actual orders.

THE HARD PARTS

What nearly broke it.

The long tail resists forecasting

Intermittent-demand SKUs are genuinely hard, and the honest answer was that point forecasts are the wrong tool. We shifted those to service-level-driven reorder points with explicit uncertainty, which is less impressive and considerably more useful.

Promotions recorded inconsistently

Historical promotions lived partly in the ERP and partly in a marketing spreadsheet with different SKU identifiers. Reconciling them took longer than training the models and mattered more to accuracy.

Earning the category team's trust

The first back-test showed the model losing to the manager on top-tier SKUs. We published that rather than hiding it, and scoped the rollout to the long tail where the win was large. Top-tier came later, on evidence.

HOW IT RAN

The timeline.

  1. 01

    Data readiness

    Weeks 1–3

    dbt models over sales and inventory history, stockout and promotion reconstruction, and an honest assessment of which SKUs had enough signal to forecast at all.

  2. 02

    Baseline & back-testing harness

    Weeks 4–6

    Statistical baseline plus rolling-origin back-tests benchmarked against the manual process — the comparison that mattered.

  3. 03

    Neural model & reconciliation

    Weeks 7–9

    Trained model for the long tail, per-SKU model selection, and hierarchical reconciliation across the category tree.

  4. 04

    WMS delivery & rollout

    Weeks 10–12

    Reorder suggestions into the WMS with confidence intervals, accuracy dashboard, and a phased rollout starting with the long tail.

OUTCOME

What changed.

Down

Stockouts on A-tier SKUs, meaningfully

Double-digit %

Reduction in inventory holding cost

Weekly

Published back-tests, including the losses

In-WMS

Suggestions delivered where POs are written

Stockouts down meaningfully on A-tier SKUs. Inventory holding cost down a double-digit percentage, freeing cash.

Freed working capital was the number the CFO cared about, and it came mostly from the long tail — thousands of small overstocks nobody had the time to think about individually.

The category manager's role shifted from producing forecasts to overriding them where their knowledge genuinely beat the model. The back-test dashboard tells them where that is.

STACK

What it's made of.

DATA

  • dbt
  • Postgres
  • Feature pipeline
  • Stockout masking

MODELLING

  • Prophet
  • PyTorch
  • Hierarchical reconciliation
  • Rolling-origin back-tests

SERVING

  • Python
  • FastAPI
  • Scheduled batch runs

DELIVERY

  • WMS integration
  • Confidence intervals
  • Accuracy dashboard

HANDOVER

What they kept.

  • Retraining runbook with the schedule, the checks, and what a bad retrain looks like.
  • Documentation of every data decision — masked stockouts, excluded periods — so future maintainers do not undo them by accident.
  • Category-team guide on reading confidence intervals and when overriding is the right call.