The source data has no historical stock balances or stockout labels, so the project does not predict or validate stockout events. It forecasts demand from past sales and applies a replenishment rule to stock levels entered by the operator. The live app sits behind a login, so the demo is not open to the public.
Stockout Radar
Demand forecasting and replenishment support, team project
Forecasts how many units of each product a small retailer will sell over the next four weeks, then compares that with the stock the operator enters to say what to reorder.
Live app (login required) – opens in new tabSource code – opens in new tab
Scope
How it works
- Online Retail II transactions (1,067,371 rows, 2009 to 2011) are cleaned into a product-by-week panel: 4,675 products, 407,702 product-weeks.
- 16 features (lags, rolling means, price, trend, calendar) use only information from before the forecast week.
- A HistGradientBoosting model predicts total units over the next four weeks. Forecasts are generated offline and stored in PostgreSQL (Neon).
- The operator enters current stock, supplier lead time and safety stock. A reorder-point rule classifies each product as reorder now, watch, or healthy and persists the result.
- A FastAPI service exposes this, and a Next.js dashboard reaches it through a server-side proxy so the API key never reaches the browser.
Results
| Metric | 4-week moving average | HistGradientBoosting |
|---|---|---|
| MAE (units) | 66.11 | 59.22 |
| RMSE (units) | 236.23 | 236.05 |
| WAPE | 53.28% | 47.73% |
The aggregate improvement is real but modest. The model has lower MAE than the baseline for 1,809 of 4,484 products (about 40%), so it does not win for most individual products. Bulk-order spikes remain hard to predict.
Limitations
Backtested on historical data only, so these are not current-market accuracy guarantees. The replenishment rule assumes demand is spread evenly over 28 days and ignores open purchase orders, supplier minimums and uncertainty intervals. There is one shared inventory space, with no user separation. A clean checkout cannot rebuild the model from raw data in one command.
My part
Team project. The original academic work was done with Muhammad Qasim (project lead, ML pipeline) and Manahil Fatima (model development); my part there was data preprocessing. This fork extends it into a deployed full-stack demonstrator with tests and CI.