Inferensys

Glossary

Backtesting

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.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
MODEL VALIDATION

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.

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.

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.

VALIDATION METHODOLOGY

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.

01

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.
No Look-Ahead
Core Principle
02

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.
03

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).
04

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.
05

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.
06

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.
BACKTESTING CLARIFIED

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.

MODEL VALIDATION METHODOLOGY

Backtesting vs. Other Validation Approaches

A comparison of backtesting against alternative validation strategies for probabilistic demand forecasting models in supply chain applications.

FeatureBacktestingCross-ValidationOut-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

Prasad Kumkar

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.