Sliding Window (Rolling Window) Cross-Validation#
Time-series CV using a fixed-size window that moves forward through time.
Important
✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.
What it is#
Sliding-window (or rolling-window) cross-validation is a time-series validation scheme where the training set has a fixed size and slides forward through time: as new data enters the window, the oldest data drops out. Like all time-series CV, it respects time order — past trains, future tests.
How it works#
Fix a window size, train on that window, validate on the next step, then slide forward and repeat. Each fold uses a same-length training block ending just before its test block.
Example#
With a 2-year window over 2020–2024: train 2020–2021 → test 2022; train 2021–2022 → test 2023; train 2022–2023 → test 2024. Notice 2020 is dropped once the window moves past it.
vs the expanding window#
The contrast is what happens to old data. An expanding window keeps all history, suiting cases where old data stays relevant (macroeconomics, cumulative learning). A sliding window discards it, suiting non-stationary settings where recent data is more predictive — financial markets, demand forecasting, IoT sensor streams.
Benefits and the size trade-off#
It keeps the model focused on recent patterns and bounds compute (the training set never grows without limit). The cost: it can forget useful long-run history, and the window size is a critical knob — too short is noisy, too long is unresponsive.
Theme: Validation & Cross-Validation · All terminology
Hint
Mind map — connected ideas
Expanding Window Cross-Validation · Blocked Splits (Single Holdout) · Cross-Validation (CV) · Temporal autocorrelation (Serial Correlation) · Time Series · Data Leakage
Hint
More in Validation & Cross-Validation
Blocked Splits (Single Holdout) · Cross-Validation (CV) · Data Leakage · Evaluation Set · Expanding Window Cross-Validation · k-fold cross-validation · k-fold Stratified Cross-Validation (Stratified CV) · Multiclass stratified CV · Stratified Group K-Fold · Stratified Shuffle Split · Time-based splits (a.k.a. Temporal Cross-Validation, Rolling Window Validation)
See also
Source article Adapted (context, re-expressed) in our own words from: Sliding Window (Rolling Window) Cross-Validation (insightful-data-lab.com).