Data note. This project runs on a synthetic retail dataset generated day by day, with demand and inventory simulated together so that true demand is known. The figures below are from the project's sample analysis run on that dataset, using the hold-out evaluation. Forward-looking recommendation figures are not quoted here because the project's code was corrected after an audit and those outputs are being regenerated.
The business problem
A retailer with many stores and products has two expensive failure modes: it stocks out and loses sales, or it overstocks and traps cash. The project is built to answer a concrete question: for this store and this product, how much will sell over the next two weeks, how much is on hand, how long does the supplier take to deliver, and how much should be reordered?
The dataset
The simulation covers 50 stores, 2,000 products (1,767 actually stocked somewhere), 40 suppliers and three years of daily activity: about 23.4 million rows across sales, inventory, purchase orders and returns.
The problem most forecasts miss: sales are not demand
When a shelf is empty, sales stop but demand doesn't. A forecast trained on raw sales learns that demand dropped on stockout days, and then under-orders the product that was already running short. I built a correction that estimates true demand on stockout days. Because the data is simulated, I could check it against the known true demand, which is not possible with real retail data. The correction cut mean absolute error on stockout days by about 45% compared with taking units sold at face value.
Forecast accuracy against honest baselines
| Method | Mean absolute error (units per day) |
|---|---|
| XGBoost | about 2.93 |
| 7-day moving average (best baseline) | about 3.06 |
| Naive and seasonal-naive baselines | about 3.9 to 4.0 |
The model beats the best simple baseline, but only by a modest margin, which is a realistic result for daily store-level demand. The larger gains in a project like this usually come from handling stockouts and from turning the forecast into an ordering decision, not from a fancier model.
Where inventory control matters most
Products were segmented by value and by how predictable their demand is (ABC-XYZ analysis). The AX group, high value and predictable, was about 7% of stocked products but about 70% of revenue. That is the group that deserves the tightest inventory control, while slow, erratic products can usually run on simpler rules.
From forecast to reorder decision
The pipeline combines the demand forecast, stock on hand and supplier lead time into a reorder recommendation and a stockout-risk flag, and includes a what-if simulator for questions such as "what happens to working capital if we raise our target service level?" Outputs are shaped as tables ready for a Power BI model, with SQL (DuckDB) for inventory health, stockout episodes and replenishment analysis.
Limitations
- The data is synthetic, so accuracy figures show that the method works, not how it would perform on your stores.
- The figures above come from the sample analysis run, and the project's own documentation lists its simplifying assumptions.
- Forward-looking recommendations and what-if figures are not quoted until the pipeline has been rerun end to end after the audit fixes.
How I would apply this to your data
For a real retailer I need sales by product, store and day, stock levels (or enough history to infer when items were out of stock), and supplier lead times. The first step is usually checking how much of your sales history was censored by stockouts, because that decides how much a hidden-demand correction will matter. The code and documentation are public: retail-demand-forecasting-inventory-optimization on GitHub. Related services: predictive analytics and forecasting and Power BI dashboards.
