Backtesting
Backtesting is checking a predictive model or strategy by running it on historical data as if it were being used at the time, then comparing its predictions with what actually happened.
To backtest a forecasting model, you pick a moment in the past, give the model only the data that existed up to that moment, and let it predict what comes next. Then you compare the prediction with what really happened, move the moment forward and repeat. The average error across all those steps estimates how well the model would have done in real use. Forecasting textbooks call this evaluation on a rolling forecasting origin.
The rule that matters most is that the model never sees the future. Ordinary cross-validation shuffles data into random groups, which is fine for independent records but leaks information when the data is ordered in time: a model could learn from next month's figures to predict this month's. scikit-learn's time series splitter avoids this by always training on earlier data and testing on the block that follows. Backtesting is, in effect, cross-validation applied to past time periods.
The term comes from finance, where traders backtest algorithmic strategies before putting real money behind them, and where Basel banking rules require large banks to backtest certain risk models by counting how often actual losses exceeded what the model predicted. Weather and ocean scientists do the same thing under the name hindcasting: they feed a model past conditions and check its output against what was observed.
In AI, backtesting is how demand forecasts, energy load predictions and weather models are judged before deployment. A good backtest is necessary but not sufficient. A strategy can be tuned until it fits the past perfectly and still fail in the future, which is overfitting by another name, and in markets a strategy cannot be backtested for its own effect on prices. When a company claims its model would have predicted past events, ask how many versions were tried before this one and whether the test period was chosen after the fact.
Backtesting is a form of cross-validation for data ordered in time. Standard cross-validation splits data randomly, while backtesting always trains on the past and tests on what came next, so no information from the future leaks into the model. The most common reason is overfitting: after many attempts, a model can be tuned to fit the quirks of past data rather than lasting patterns. Conditions also change over time, and in finance a strategy that trades at scale can move prices in ways historical data cannot reflect. Hindcasting is the name used in meteorology and oceanography for backtesting. Scientists run a model over a past period using known or estimated inputs and compare its output with what was actually observed, to check how well the model reproduces reality. Yes, for any model that forecasts something over time, such as sales, energy demand, prices or weather. Splitting data so that the model only learns from the past is the standard way to estimate how such a model will perform once deployed.Common questions
What is the difference between backtesting and cross-validation?
Why do strategies that backtest well fail in real use?
What is hindcasting?
Is backtesting used for AI models?
Search for "time series cross-validation", "walk-forward validation" or "backtest overfitting". Forecasting textbooks such as the freely available <em>Forecasting: Principles and Practice</em>, the documentation of libraries like scikit-learn and banking regulators' publications on model validation are dependable sources. Treat published backtest results from trading or forecasting vendors with caution, since they usually show the best of many attempts.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.