Probabilistic Demand Forecasting for Fresh-Food Replenishment

Build a forecasting system that predicts every store's demand for every fresh item as a calibrated distribution, learns past its own stock-outs, orders by what waste and empty shelves cost, proves itself in rolling-origin backtests and a replenishment simulation, and is released, published and monitored behind a pre-registered gate.

Machine Learning Engineer. Advanced.

What you will build and explain

  • Frame a forecasting problem from the decision it serves: grain, horizon, lead time and the costs of each kind of error.
  • Keep the future out of training and backtests with as-of database views, per-job roles and an as-of check in code.
  • Evaluate forecasts with rolling-origin backtests and measures suited to small counts (WAPE, MASE, bias, pinball loss) against strong baselines.
  • Train one global LightGBM model per horizon group across thousands of series, with the direct multi-horizon strategy.
  • Recognise stock-out censoring and correct for it, and measure the correction against true demand.
  • Turn point forecasts into calibrated count distributions and verify coverage with the randomised PIT.
  • Reconcile forecasts across a store-by-product hierarchy and choose the method by measurement.
  • Order at each department's critical ratio, price ordering policies in a simulation with ageing stock, and release, publish, roll back and monitor a model behind a gate.

Before you begin

  • Write Python with pandas or Polars and pytest, and SQL with joins and GROUP BY; explain a mean, a variance and a quantile.
  • Have trained a scikit-learn model and evaluated it on a held-out set.
  • Use a terminal, Git and Docker Compose, and read HTTP requests and JSON responses.
  • A computer with 4 or more CPU cores (8 recommended) and 8 GB of free disk, running Linux, macOS or Windows with WSL 2.
  • Time-series cross-validation, gradient-boosted trees, intermittent demand, censoring, calibration, reconciliation and inventory models are taught in the project.

Who this is for

For engineers who write Python with pandas and pytest, have trained a scikit-learn model, know what a mean, a variance and a quantile are, and use Docker Compose, and want to build a forecasting system that drives real decisions: leakage-safe backtests, a global gradient-boosted model, stock-outs treated as censored demand, calibrated count distributions, plans that add up, orders priced by what waste and empty shelves cost, and a release that is monitored after it ships.

Curriculum

Learning topics (13)
  1. Check what you need before the first command

    This project builds a forecasting system that decides how much fresh food ten stores order every evening. You do not need any background in time-series forecasting, gradient-boosted trees, censored data, calibration or inventory models: the lessons teach those. You do need some programming, a little statistics and a computer that can run a few containers. This page says exactly which, and how to check each one before you start.

  2. Follow one evening through the system

    Larkfield Market's fresh departments order every evening for delivery two mornings later. This system forecasts each store's demand for each fresh item over the next 14 days, as a distribution rather than a single number, and turns that distribution into an order sized by what a lost sale and a wasted unit cost. It proves itself on past data before it is released, publishes forecasts and orders the ordering system can read, and watches its own accuracy as the real days arrive

  3. Frame the forecast from the decision it serves

    "Forecast demand" is not a task anyone can finish. Demand for what, where, how far ahead, at what grain, and judged how? The answers come from the decision the forecast feeds. At Larkfield Market that decision is concrete: every evening, a store manager orders each fresh item for delivery two mornings later. This lesson works out what that decision needs from a forecast, and why the answer is a distribution for each store, item and day rather than a single weekly number.

  4. Generate the history and keep the future out

    A forecasting project lives or dies on its data, and on one rule about it: a forecast made on an evening may use what was known that evening and nothing later. This lesson shows where Larkfield's data comes from, what it records and what it hides, and the two guards that keep every model on the right side of that line.

  5. Measure forecasts the way they will be used

    You have trained a model and it scores well on a test set. Would it have helped the stores last quarter? A random train/test split cannot say, because it lets the model learn from days after the ones it is tested on: it has seen the future. This lesson builds the measurement the whole project relies on: replay past evenings, forecast with only what was known then, and score the forecasts with measures that make sense for thousands of noisy, often tiny, counts.

  6. Set the baselines a model has to beat

    A gradient-boosted model with twenty features sounds better than "same as last week". Whether it is better is an empirical question, and the answer is often "barely" or "only for some items". This lesson sets up the baselines every backtest runs at every cut-off, from the chain's own spreadsheet to statistical models built for items that sell only now and then, and explains what each one is good at.

  7. Forecast 2,440 series with one model per horizon

    The classic way to forecast a store's sourdough is to fit a model to the sourdough's own history. With 2,440 store-item series, that means 2,440 models, each blind to what the others know: that every bakery item sells more on Saturdays, that a promotion lifts demand, that a new yoghurt behaves like the old ones. This lesson builds the opposite: one global model trained on every series at once, and the feature design that lets it forecast 14 days ahead without ever needing a v

  8. Learn demand from sales that hit the ceiling

    When the last sourdough sells at three o'clock, the till records the sales of a day that was cut short. Train on those numbers as if they were demand and the model learns that demand is low exactly where the shelves were too empty, so the next orders are smaller, so the shelves empty again. This lesson shows why the obvious fixes make it worse, and how the project uses a sold-out day for what it really says: demand was at least what sold.

  9. Turn forecasts into calibrated distributions

    The order rule asks for a different quantile of demand in every department: about the 50th percentile for bakery, near the 90th for dairy. A single forecast number cannot answer that. This lesson turns the model's mean into a full distribution for each store, item and day, then asks the question that matters more than any accuracy score: when the forecast says "90 % of the time demand stays below 9", is that true?

  10. Make store, region and category plans add up

    The Coast regional manager plans next week's staff from a forecast of the region's fresh sales. Each Coast store orders from its own item forecasts. If the region's forecast says 9,000 units and the stores' item forecasts add up to 8,200, one of them is wrong and two teams are planning against different numbers. This lesson builds the store-by-product hierarchy, explains why forecasts made separately at each level disagree, and shows two ways to make them coherent: every leve

  11. Turn forecasts into orders and price them

    A forecast is worth what the decisions made from it are worth. This lesson builds the order rule that turns a demand distribution into units on a delivery note, then the replenishment simulation that replays real days with ageing stock to measure the waste and the empty shelves each ordering policy would have caused. The release gate's decisive test, G3, comes from this simulation.

  12. Release, publish and roll back a model

    A model that passed a backtest on Tuesday is not yet the model the stores order from. Someone has to decide it is good enough, the ordering system has to receive its forecasts without ever seeing half of them, and when it turns out worse than expected there has to be a way back that takes a minute, not a day. This lesson walks through the release path: the registry, the gate, atomic publication, the read-only API and rollback.

  13. Know when the model stops being right

    The backtest says how the model did on the past. The stores live in the future, where a competitor can open beside one of them and a heat wave can double salad sales for a week. This lesson builds the loop that runs after release: play each new day, score the forecasts that covered it, and raise an alert when the errors stop looking like the backtest's, using only what the chain itself can observe.

Practical build steps (11)
  1. Prepare and check your computer

    Starting point: nothing yet. End point: you know your computer has the cores, disk, tools and free port the lab needs.

  2. Build the image and run the unit tests

    Starting point: a checked computer and the source folder. End point: the project image is built and every unit test passes inside it, with no network.

  3. Start the stack

    Starting point: the image. End point: secrets, the synthetic data, and PostgreSQL and the ordering API running and healthy, with only the API published on your loopback interface.

  4. Check the boundary

    Starting point: a running stack. End point: you have seen the database refuse the forecaster the future and the true demand, and the API's login refuse any write.

  5. Run the backtest

    Starting point: a running stack. End point: a report of how the configured system would have done at six past cut-offs, with every baseline, the simulation of orders and the gate's verdict.

  6. Train, promote and publish

    Starting point: a backtest that passed. End point: a current model and tonight's forecasts and orders, published as one complete batch.

  7. Read the forecasts and orders

    Starting point: a published batch. End point: you have read it through the API as the ordering client and on the planner page.

  8. Release a second model and roll it back

    Starting point: a current model. End point: you have promoted a second version, gone back to the first, and seen the next batch use it.

  9. Operate through the held-back weeks

    Starting point: a current model and a published batch for day 729. End point: three weeks played through the stores, every day scored, and alerts you can read against what happened.

  10. Retrain after the change

    Starting point: alerts raised after day 744. End point: a new backtest that includes the changed weeks, a gate decision on the retrained model, and the remaining five weeks played.

  11. Clean up

    Starting point: a lab you have finished with. End point: nothing of the project remains on your computer except the source folder.

Access

Learning Access: INR 199 plus 18% GST. Source Pack: INR 399 plus 18% GST. 90 days of online access. No auto-renewal.

Cloud costs and boundaries

Runs entirely on your computer with Docker Compose: about 2 GB of image and package downloads and a synthetic dataset generated locally. No cloud account, API key, payment method or hosted lab is used or included. The timings quoted in the lessons were measured on an 8-vCPU Graviton cloud virtual machine; reproducing them on similar hardware is optional and at your own cost.

Licence and completion

Vectametric Project Source Licence (2026-09-27): lawfully obtained source may be copied, modified and deployed for personal learning and interview preparation, including personal portfolio demonstrations with attribution. These permissions continue after online access expires. Do not resell or redistribute the Source Pack or its original source files, unchanged or modified. Commercial or client production use requires separate written permission. The container images and Python packages downloaded when building or running, such as PostgreSQL, LightGBM, StatsForecast, HierarchicalForecast, pandas and FastAPI, retain their own licences. See LICENSE.txt and the Project Source Licence section of the site Terms for the full rules.

Questions about projects

Do I need a cloud account?

You can read the project material without deploying it. Running a cloud build requires the accounts, permissions and tools listed in that project's prerequisites. Deployment runs in your environment, not in a hosted Vectametric lab.

Can I read the code with Learning Access?

Yes. Learning Access includes the online source-file browser and explanations. The Source Pack adds the downloadable reference repository where available. The project's licence governs use of the source.

Are cloud charges included?

No. Cloud and CI usage are separate. Read the project's cost notice, set a budget and stop deadline, and follow its destruction and leftover-resource checks.

Does the project include troubleshooting and interview preparation?

The project curriculum lists the available scenarios and interview topics. These focus on understanding the architecture and explaining decisions; they are not a promise of particular interview questions or a job.

How long can I use the project?

The project page and checkout show the online access period for your selected plan. Access does not auto-renew. Downloaded source remains subject to its licence; future releases are not automatically included.

Review the Terms and No-Refund Policy before confirming access. All sales are final; Vectametric does not offer refunds.

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy