Backtesting is the process of evaluating a forecasting model's performance by applying it to historical data and comparing its predictions against actual outcomes using a rolling or expanding window. This technique simulates how the model would have performed in a real-world production setting, providing a rigorous, out-of-sample validation that simple in-sample error metrics cannot offer.
Glossary
Backtesting

What is Backtesting?
Backtesting is the standard methodology for evaluating a forecasting model's predictive accuracy by simulating its performance on historical data where the actual outcomes are already known.
The methodology involves training the model on a specific historical window, generating a prediction for the subsequent period, and then advancing the window forward to repeat the process. This prevents data leakage and ensures the model is judged on its ability to generalize to unseen data, making it the definitive test for probabilistic demand forecasting systems before deployment.
Key Characteristics of Backtesting
Backtesting is the systematic evaluation of a forecasting model's predictive accuracy by applying it to historical data and comparing its outputs against known actual outcomes. It is the primary mechanism for establishing trust in a model before production deployment.
Temporal Cross-Validation
Unlike standard k-fold cross-validation, backtesting respects the temporal ordering of data to prevent look-ahead bias. The model is trained on a historical window and tested on a subsequent, unseen period. Common strategies include:
- Expanding Window: The training set grows to include all prior data, mimicking a production model that accumulates history over time.
- Rolling Window: A fixed-size training window slides forward, discarding old data to adapt to recent patterns.
- Walk-Forward Optimization: A specific form of rolling window where the model is retrained at each step, rigorously testing stability.
Point Forecast Error Metrics
Standard accuracy measures quantify the deviation between the point forecast and the actual observed value. Key metrics include:
- MAE (Mean Absolute Error): The average absolute difference, providing an intuitive measure in the original units.
- RMSE (Root Mean Squared Error): Penalizes large errors more heavily than MAE, making it sensitive to outliers.
- MAPE (Mean Absolute Percentage Error): Expresses error as a percentage, useful for communicating with business stakeholders but undefined when actuals are zero.
- sMAPE (Symmetric MAPE): Addresses MAPE's asymmetry by dividing by the average of forecast and actual.
Probabilistic Forecast Evaluation
For models that output a full prediction distribution, point metrics are insufficient. Proper scoring rules evaluate the entire distribution:
- Continuous Ranked Probability Score (CRPS): Measures the integrated squared difference between the predicted CDF and the empirical observation. It generalizes MAE for probabilistic forecasts.
- Pinball Loss: Evaluates a specific quantile forecast. It asymmetrically penalizes over-prediction and under-prediction based on the target quantile, directly optimizing for service-level goals.
- Prediction Interval Coverage: Checks if the true value falls within the predicted interval at the nominal rate (e.g., a 90% interval should contain the truth 90% of the time).
Bias and Residual Diagnostics
A model with low aggregate error can still be systematically flawed. Residual analysis examines the pattern of errors over time:
- Mean Error (ME): A non-zero value indicates persistent forecast bias (consistent over-forecasting or under-forecasting).
- Autocorrelation of Residuals: Significant autocorrelation suggests the model is not capturing all temporal structure, leaving exploitable signal in the errors.
- Heteroscedasticity: A funnel shape in residual plots indicates that error variance changes with the forecast level, violating assumptions of many statistical models.
Backtesting with Covariates
When models use external features like pricing, promotions, or weather, backtesting must ensure causal integrity. Using future information for a past prediction constitutes data leakage. The process must replicate the production state:
- Feature Lagging: Ensure covariates are shifted to reflect the information available at the forecast origin.
- Ex-Ante vs. Ex-Post: Distinguish between forecasts made with actual known future covariates (ex-post) for diagnostic purposes and those made with forecasted covariates (ex-ante) for realistic performance assessment.
- Scenario Testing: Apply historical shock events (e.g., a supplier bankruptcy) to the feature set to evaluate model resilience under stress.
Financial and Operational Evaluation
Statistical accuracy does not guarantee business value. The ultimate backtest translates forecast errors into operational and financial impact:
- Inventory Simulation: Feed backtested forecasts into an inventory policy (e.g., newsvendor model) to simulate realized holding costs, stockout events, and service levels.
- Waste vs. Shortage Cost Curves: For perishable goods, evaluate the trade-off between spoilage from over-forecasting and lost revenue from under-forecasting.
- Decision-Focused Evaluation: Weight errors by their asymmetric business cost. A stockout at a high-margin customer is penalized more heavily than an overstock of a low-cost item.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about evaluating forecasting models against historical data.
Backtesting is the systematic process of evaluating a predictive model's performance by applying it to historical data and comparing its forecasts against actual, known outcomes. The core mechanism involves simulating a realistic deployment scenario: you select a point in the past, train your model only on data available up to that point, generate a forecast for a future horizon, and then compare that forecast to the actual data that subsequently occurred. This process is repeated by advancing the training window forward in time—a technique known as a rolling window or expanding window validation. For a demand forecasting model, this means you might train on sales data from January 2022 to June 2023, forecast July 2023, and then measure the error against the real July 2023 sales. You then roll the window forward to include July 2023, retrain, and forecast August 2023. This strict temporal discipline prevents data leakage, where information from the future inadvertently contaminates the training set, which would produce unrealistically optimistic performance metrics. The output is a distribution of error metrics—such as Mean Absolute Percentage Error (MAPE) or Continuous Ranked Probability Score (CRPS)—calculated across all simulated forecast horizons, giving you a robust, out-of-sample estimate of how the model will perform in production.
Backtesting vs. Other Validation Approaches
A comparison of backtesting against alternative validation strategies for probabilistic demand forecasting models in supply chain applications.
| Feature | Backtesting | Cross-Validation | Out-of-Time Validation |
|---|---|---|---|
Temporal Order Preservation | |||
Data Leakage Risk | Low | High | Low |
Historical Simulation Fidelity | High | Low | Medium |
Handles Concept Drift Detection | |||
Computational Cost | High | Medium | Low |
Statistical Efficiency | Medium | High | Low |
Suitable for Rolling Window Evaluation | |||
Requires Sequential Data Structure |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Mastering backtesting requires understanding the statistical frameworks, validation strategies, and performance metrics that ensure a forecasting model generalizes to unseen data rather than memorizing historical noise.
Walk-Forward Validation
The gold-standard backtesting methodology that simulates real-world deployment by incrementally rolling the training window forward. At each step, the model is trained on data up to time t, predicts for t+1, then the window expands to include t+1 before retraining. This prevents look-ahead bias and provides a realistic measure of how a model adapts to concept drift. Unlike standard k-fold cross-validation, walk-forward preserves the temporal order of observations, making it essential for non-stationary supply chain data.
Continuous Ranked Probability Score
A strictly proper scoring rule that evaluates the full predictive distribution, not just a point estimate. CRPS measures the integrated squared difference between the predicted cumulative distribution function and a step function at the observed value. Lower scores indicate better probabilistic calibration. Unlike Mean Absolute Error, CRPS rewards models that correctly express epistemic uncertainty—penalizing both overconfident wrong predictions and underconfident vague ones.
Pinball Loss Function
An asymmetric loss function central to quantile regression backtesting. It applies a weight of τ to positive errors and (1-τ) to negative errors, where τ is the target quantile. For a 95th percentile forecast, under-prediction is penalized 19 times more heavily than over-prediction. This allows backtesters to verify that prediction intervals achieve their nominal coverage—a 90% interval should contain the actual value exactly 90% of the time across a sufficient test window.
Forecast Reconciliation
The post-hoc adjustment process that ensures hierarchical coherence across backtested forecasts. When bottom-up SKU-level predictions are aggregated, they must mathematically equal top-down category forecasts. Reconciliation algorithms like MinT (Minimum Trace) optimally distribute errors across the hierarchy using the covariance structure of base forecast errors. Without reconciliation, backtesting results at different aggregation levels will show inconsistent accuracy metrics, undermining trust in the system.
Diebold-Mariano Test
A statistical hypothesis test that determines whether the difference in forecast accuracy between two competing models is significant or merely due to random chance. The test accounts for autocorrelation in forecast errors and can be applied to any loss function. In backtesting, it answers the critical question: Is Model A genuinely superior to Model B, or did it just get lucky on this particular historical window?
Look-Ahead Bias Prevention
The most insidious failure mode in backtesting, where information that would not have been available at prediction time leaks into the training process. Common causes include: - Scaling features using future min/max values - Applying PCA fit on the entire dataset - Using supplier lead times that were revised retroactively - Training on demand data that was later adjusted for returns Rigorous temporal point-in-time snapshots of the feature store are the primary defense.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us