liveBook · Manning

Rolling cross-validation

As explained in Machine Learning System Design

A time-ordered cross-validation procedure that repeatedly advances training and validation windows through a series.

Rolling cross-validation evaluates time-series models by moving nonrandom training and validation windows forward through timestamps. Training always uses the past to predict a later period, avoiding future-to-past leakage. section 7.2.4

Configure each rolling split around the way the model will operate in production:

  • Match the validation-window size to the forecast horizon and the time the model will run before retraining. section 7.2.4
  • Choose either all available history or a limited recent window, depending on whether older patterns remain relevant. section 7.2.4
  • Align training and validation windows with seasonality; yearly patterns may require at least two years, while weekly folds should contain matching weekdays. section 7.2.4
  • Insert a gap when data arrives late or when reducing correlation between training and validation observations helps limit leakage. section 7.2.4

Retail demand forecasting

A demand model predicts four weeks ahead using five outer rolling folds. Each fold trains on two years, validates on 28 days, leaves a three-day gap, and advances seven days. A three-fold inner rolling loop tunes hyperparameters and selects features inside each outer training set. section 7.5.1

Figure 7.4 Standard time-based split. The test dataset always follows the train one, so train samples are “past” and test is “future.”
figure

Use the time-based split diagram to anchor the central rule: every test period follows its training period in time. section 7.2.4

How Machine Learning System Design covers it

How deep it goes
Explains window size, training history, seasonality, gaps, fold counts, and nested tuning, without deriving implementation code.
Examples
Uses four-week retail forecasts with two-year histories, three-day gaps, seven-day steps, and nested inner and outer folds.
What it assumes
Assumes timestamped observations and a defined forecast horizon while teaching temporal ordering, seasonality, delayed data, and leakage concerns.
What you can do after
Apply it to estimate time-series performance, tune models, and choose windows that reflect forecast and retraining operations.
How it connects
Connects time-series validation with cross-validation, holdout sets, seasonality, data leakage, hyperparameter optimization, and feature selection.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning System Design. The section links point to the parts of the book it draws on.