Build a Time-Based Backtest for Weekly Demand Forecasts
Last updated: November 29, 2026
Quick Overview
A data scientist validated a weekly demand forecasting model for Amazon retail with random k-fold cross-validation and got excellent scores that did not hold in production. Explain what went wrong and design a correct backtesting scheme.
Amazon
November 29, 20260
0
0 solved
A data scientist validated a weekly demand forecasting model for Amazon retail with random k-fold cross-validation and got excellent scores that did not hold in production. Explain what went wrong and design a correct backtesting scheme.
Forecasting drives Amazon's buying and inventory placement, so supply chain science interviews probe whether candidates validate time series properly. The interviewer looks for leakage awareness, rolling-origin evaluation and attention to forecast horizon.
What the Interviewer Expects
- Explains how random folds leak future information through lags and trends
- Designs a rolling-origin or expanding-window backtest
- Matches the evaluation horizon and lead time to the business decision
- Recomputes features inside each fold using only past data
- Covers peak events such as Prime Day and Q4 in the backtest windows
Key Topics to Cover
How to Approach This
- Understand the bias-variance trade-off. High training accuracy but low test accuracy signals overfitting.
- Choose evaluation metrics carefully based on the problem. Accuracy alone is often insufficient.
- Feature engineering is often more impactful than model selection.
- Know when to use tree-based models (tabular data) vs neural networks (unstructured data).
- Handle class imbalance with SMOTE, class weights, or appropriate loss functions.
Possible Follow-up Questions
- How many backtest origins would you use, and why?
- How do you handle products launched midway through the history?
- How would you tune hyperparameters without overfitting to the backtest?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Explore ML Interview PrepSample Answer
Clarify
Ask what decision uses the forecast (a buying decision made 8 weeks ahead), how long the history is, and which features are lagged sales, prices, promotions or events....
Approach
Random k-fold puts week t+1 in training while testing week t, so the model learns from the future. Lagged and rolling features computed on the full table make it worse. The fix is to always train on d...