Evaluate the complete forecasting procedure through time
Replay repeated issue cutoffs with mature labels, causal preprocessing, and a deployment-matched update schedule.
On this page
The question for today
What you’ll understand
- Construct expanding and sliding historical training windows.
- Compute a maturity gap without imposing an arbitrary lag-window embargo.
- Separate model selection from final temporal evaluation.
A random row split can place a forecast from Friday in training while testing a forecast from Tuesday. That is a poor rehearsal for a model that will be trained on the past and deployed into the future. Rolling-origin validation moves the issue cutoff forward and reconstructs training, features, and predictions at each step. The object under evaluation is the whole procedure, including retraining cadence and state updates. A correct split diagram is only the start: preprocessing and delayed labels must obey the same clock as the model fit.
Replay the deployed update policy
At each origin, assemble the data and labels that would have been usable for that fit, apply transformations learned from its legal training window, and issue the intended horizons. An expanding window retains all earlier eligible examples; a sliding window retains a fixed recent span. Expanding history offers more observations but may mix obsolete regimes. Sliding history adapts its population at the cost of smaller samples. Choose between them using the expected process and historical evidence rather than treating either as universally correct.
The retraining schedule matters independently of the forecast schedule. A service may issue hourly forecasts with parameters refitted each night and state updated after every accepted observation. A backtest that refits the model at every hourly origin gives it a different computational budget and potentially fresher parameters. Reproduce the actual cadence, including training runtime if it delays artifact availability. A fit started at midnight cannot serve its new weights at midnight if it finishes forty minutes later.
Derive gaps from information eligibility
A gap between training origins and test origins can enforce outcome maturity when labels extend into the future. Suppose a training example at i predicts y at i+h and that label is usable d periods later. At fit cutoff C, its origin must satisfy i+h+d≤C. Derive that inequality from the target and finalization definition. A library’s integer gap is a row exclusion mechanism; it does not inspect your target intervals, revision times, feature availability, or training completion schedule.
Do not automatically forbid a test lag from reading a measurement that also appears in training. Real forecasts normally consume recent observed history. Reusing that legal history is different from fitting parameters on future labels. Conversely, overlapping multi-step outcomes can make errors across origins strongly dependent even when no leakage occurs. Document the overlap and use an uncertainty procedure that respects temporal dependence. A split can be causally valid without producing independent evaluation cases.
Keep the final future unseen during selection
Use earlier rolling folds to choose hyperparameters, feature policies, and retraining settings, then assess the chosen procedure on a later untouched period. Repeatedly modifying the system after inspecting final-period scores turns that period into another validation set. For a global model, split on actual time across entities unless the deployment question specifically concerns unseen entities. Otherwise contemporaneous future outcomes from one entity may influence a shared model used to score earlier decisions for another.
Save predictions before joining outcomes. Their records should include origin, target interval, horizon, model artifact, feature snapshot, and any fallback status. This allows the same issued forecast to be scored under provisional and final truth without regenerating predictions using newer data. Audit several folds by hand, especially the first row after a boundary and the first row after a retrain. These small checks often expose off-by-one errors that a large aggregate accuracy table hides.
Work it through
A two-step target with one-step label delay
Origins are integer hours. Each row i predicts the point outcome y at i+2, usable one hour later. The first test issue and fit cutoff are both C=20, and training artifacts are assumed instantaneous for this toy calculation. Determine the latest train origin and skipped origins.
A row at i has target time i+2 and usable label time i+3. Enforce i+3≤20, yielding i≤17. Labels at the cutoff itself are permitted by the stated equality rule.
The final train origin is 17. Origins 18 and 19 lie strictly between 17 and the test origin 20, so the row gap is 2 rather than 3.
At the next independently refitted cutoff 21, origin 18 becomes eligible. If deployment does not refit until cutoff 24, that row instead waits for the actual scheduled fit.
The necessary gap follows from label maturity and the library’s row-count convention. It does not imply that the forecast at 20 must discard legally observed recent inputs.
The living notebook
Explore the model
Interactive lab · optimization
A restart is different from changing a parameter mid-clock
Reset, set Step size η to 0.5 and Initial position x₀ to 2. Predict x₁=1 and x₂=0.5 after one and two Steps. At that retained elapsed time, changing η to 1 recomputes the initial-value formula at n=2, yielding x₂=0; it does not take a single new update from 0.5. For a fresh comparison, Reset, set η=1 and x₀=2, then Step. This is quadratic descent, not a forecasting backtest.
- Position x0
- 2
- Objective x²/2
- 2
- Iteration behavior
- Stable step
Gradient descent on f(x) = x²/2: xₙ = (1 − η)ⁿx₀. Playback advances two discrete iterations per second. Values outside |x| ≤ 4 are explicitly reported. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.
Look forSpecify restart, state update, and refit semantics before comparing procedures.
Pause & reason
Check your understanding
Your turn
Try it yourself
A point target has horizon h=4 and fixed label delay d=2 on an hourly grid. A fit cutoff and test origin are C=30. What is the latest eligible training origin and the number of skipped rows?
Take a moment to make a prediction or work it out on paper. Open a hint when you need one.
Give me a hint
First solve i+h+d≤C, then count only origins strictly between the last training origin and 30.
Compare with the solution
The latest training origin is 30−4−2=24. Origins 25,26,27,28,29 are skipped, giving a row gap of 5. A different interval target, irregular origin schedule, or delayed artifact completion would require recalculating the timeline rather than reusing this integer gap.
Keep the idea
Take it with you
- Evaluate update cadence, preprocessing, and data eligibility together.
- Derive any gap from target maturity and exact row conventions.
- Preserve issued predictions before outcomes are attached.
Read further
Original sources and deeper explanations to follow at your own pace.
Optional progress, saved in this browser when available. Revisit any lesson at any time.
Lesson not marked complete.