Data Science / ML · Case study 05

QuickCommerce Demand Intelligence & Personalization Engine

Predict demand, restock smartly, target the right customers — one command reproduces every number.

The problem

A 10-minute delivery promise only works if each dark store holds the right stock — not so much that it spoils, not so little that orders are lost — and if promotions reach customers who will actually use them.

The build

1.3M simulated order lines across 50K users, 500 products, 12 zones and 90 days, with realistic demand shapes (morning rush, late-night snacks, rain, payday). PySpark feature engineering, K-Means RFM segmentation, XGBoost forecasting against regression baselines, Gaussian Processes for calibrated uncertainty, a Gymnasium RL restocking agent, active learning, A/B test design with power analysis, and SHAP for explainability.

Architecture

— one teal highlight: the uncertainty layer

What I found

Forecast accuracy alone doesn't decide restocking — uncertainty does. Point forecasts under 15% MAPE still leave the wrong reorder decision when the interval is wide, which is why the Gaussian Process layer exists alongside XGBoost rather than instead of it.

The reps

The hardest part was making the simulator honest: demand that ignores rain, payday and hour-of-day makes every model look better than it deserves.

Results

  • 1.3M
    order lines simulated
  • <15%
    MAPE with calibrated intervals
  • 5
    named RFM segments
  • 1
    command reproduces every number

What's verified

Every case study carries this block

What was measured, and what was not. Nothing in the second column is estimated into the first.

Measured

Every number in the README is produced by run_pipeline.py on the simulated dataset and written to results.json.

Not executed

Data is simulated, not production. No live A/B test was run — the design includes power analysis only.

PythonXGBoostscikit-learnPySparkGaussian ProcessesGymnasium (RL)SHAPLangChain / RAG
View repository →