Time series cross-validation is a model evaluation procedure that trains only on past observations and tests on the periods that follow, repeating this split at several points in time to estimate how well a forecasting model will perform on genuinely unseen future data. Within time series & forecasting, a core area of artificial intelligence and machine learning, it is also known as rolling-origin evaluation or walk-forward validation.
Ordinary k-fold cross-validation shuffles data into random folds, which lets a model see the future while predicting the past. Because consecutive observations are correlated, that shortcut produces optimistic error estimates and can select models that fail in production. Time series cross-validation respects the arrow of time, so the measured error reflects the conditions under which the model will actually be used.
How rolling-origin evaluation works
Rolling-origin evaluation works by moving a forecast origin forward through the series. At each origin, the model is fitted on all data up to that point, it produces forecasts for the chosen forecast horizon, and those forecasts are compared with the observed values; the errors from all origins are then averaged.
The procedure has a small number of design parameters. The table below lists them and explains what each one controls.
| Parameter | What it controls | Typical choice |
|---|---|---|
| Initial training window | Data available to the first fit | At least two full seasonal cycles |
| Forecast horizon | How far ahead each test reaches | Matches the business horizon |
| Step size | Distance between successive origins | One period up to one horizon |
| Number of folds | How many origins are evaluated | 5 to 50, limited by compute |
| Gap | Periods skipped between train and test | Equal to data latency or lag length |
| Refit frequency | Whether the model is retrained per fold | Every fold, or every few folds |
The gap parameter is often overlooked. When features use lagged or rolling values, or when data arrives with a reporting delay, the gap prevents information from the test period from leaking into the last training rows.
Expanding, sliding and blocked schemes
Time series cross-validation comes in several split schemes that differ in how the training window behaves as the origin moves. The right scheme depends on whether old data remains relevant and on how much the process changes over time.
The following table compares the common schemes.
| Scheme | Training window | Best suited to | Main drawback |
|---|---|---|---|
| Expanding window | Grows from a fixed start | Stable processes, short histories | Old regimes may dominate |
| Sliding window | Fixed length, moves forward | Drifting or changing processes | Discards useful history |
| Blocked cross-validation | Contiguous blocks with buffers | Stationary series, small datasets | Trains on some future data |
| Single holdout | One split at the end | Quick checks, very long series | High variance, one period only |
| Purged and embargoed splits | Removes overlapping labels | Financial labels spanning time | Smaller effective sample |
An expanding window is the usual default for classical models such as ARIMA and the ETS model. A sliding window is preferred when the data shows structural breaks, because it measures how the model performs with only recent, representative history.
Choosing metrics and aggregating fold errors
Fold errors must be measured with scale-appropriate metrics and aggregated with care. MASE is often preferred over MAPE because it remains defined when actual values are zero and it compares the model with a naive forecast on the same series.
Errors should also be reported per horizon step, since a model may be excellent one day ahead and weak a week ahead. For probabilistic forecasting, the same splits are scored with pinball loss or interval coverage rather than point accuracy.
The table below shows how evaluation choices change with the forecasting setting.
| Setting | Recommended metric | Aggregation approach |
|---|---|---|
| Single series, positive values | MAPE or MASE | Mean over folds and horizons |
| Many series with different scales | MASE or scaled RMSE | Average of scaled errors |
| Intermittent demand | MASE or cost-based loss | Total over folds |
| Quantile forecasts | Pinball loss | Mean per quantile level |
| Hierarchical forecasts | Scaled error per level | Weighted by business value |
Using cross-validation for model selection
The main practical use of time series cross-validation is choosing between models and hyperparameters under realistic conditions. Libraries such as scikit-learn’s TimeSeriesSplit, sktime and GluonTS provide ready-made splitters, while statistical packages offer rolling-origin functions for classical models.
A disciplined workflow keeps a final untouched test period at the end of the series. Cross-validation folds are used to tune and compare candidates, and the final period gives a single unbiased estimate for the chosen model, in the same way as a standard train-test split.
- Fit all preprocessing inside each fold, including scaling, imputation and feature selection.
- Compute lag features and rolling window features only from data available at the forecast origin.
- Compare every candidate against a seasonal naive benchmark on identical folds.
- Report the spread of fold errors, not only the mean, to reveal unstable models.
Pitfalls and sources of leakage
Most failures of time series cross-validation come from subtle look-ahead leakage rather than from the split scheme itself. A model can pass validation and still fail once deployed if any fold used information that would not exist at forecast time.
| Mistake | Symptom | Fix |
|---|---|---|
| Shuffled k-fold splits | Validation error far below live error | Use ordered, forward-only splits |
| Global normalization | Slightly optimistic scores | Fit scalers inside each fold |
| Revised data used as final | Live accuracy drops after launch | Use point-in-time data vintages |
| Too few folds | Rankings change between runs | Add origins or vary step size |
| Missing gap | Lag features leak target values | Insert a gap equal to the lag |
Compute cost is the other limitation. Deep forecasters such as N-BEATS or the Temporal Fusion Transformer can be expensive to refit at every origin, so teams often refit less frequently or reuse weights, accepting a small loss of realism.
Understanding it simply
A forecast is only useful if it works on days that have not happened yet. Time series cross-validation tests a model the same way. It hides the future, lets the model learn from the past, and then checks its guesses.
Then it moves forward in time and repeats the test. Imagine grading a weather forecaster each morning on tomorrow’s weather, for a whole season. One lucky day proves little. Many days in a row show the true skill. The key takeaway is that a model must never peek at the future during testing.
Applied in practice
A regional grocery chain forecasts daily demand for 3,000 products fourteen days ahead to plan orders. Its data science team holds three years of sales history and compares a seasonal naive benchmark, an ETS model and a gradient-boosted global model with lag and calendar features.
The team sets an expanding window with weekly origins over the final year, a fourteen-day horizon and a two-day gap for delayed sales reporting, giving 52 folds. A random k-fold test had suggested the boosted model was 30 percent better than ETS. Under walk-forward validation the advantage shrinks to about 8 percent in MASE, and it holds across most folds. The chain deploys the boosted model with realistic accuracy expectations and a documented benchmark for later monitoring.