Why is ordinary shuffled k-fold cross-validation wrong for time-series data, and what should you do instead?

ML systems and evaluation, Validation
Level L2 Elementary. Length Short. Nature Th Theoretical.

What's being asked

Whether you recognise temporal leakage and know forward-chaining validation.

Key idea

Shuffled k-fold trains on the future to predict the past and puts autocorrelated neighbours in both training and validation folds, so the score is optimistic. Validate the way you deploy: train on data up to time t, validate on data after t, and roll forward.

Steps

  1. Name the two problems: look-ahead (future information in training) and dependence (neighbouring points are near-copies, so the validation data is not really unseen).
  2. Describe forward chaining (expanding window): fold k trains on periods 1,…,k and validates on period k+1. Use a sliding window of fixed length instead if old data is stale.
  3. Add a gap (embargo) between training and validation at least as long as the feature look-back or the label horizon, so overlapping windows cannot leak.
  4. Fit all preprocessing (scalers, target encodings, lag features) on each training fold only. Keep the most recent period as a final test set.

Common mistakes

How long your answer should be

4–5 sentences, ideally with a small diagram of the folds.

Last checked on 4 December 2026.

Read this

Previous in ML systems and evaluation: A search system returns four documents whose graded relevance, in rank order, is [3,2,0,1] (higher is more relevant; 0 is irrelevant). What are precision@3 and NDCG@4, using DCG@k=∑i=1krelilog⁡2(i+1)?
Next in ML systems and evaluation: What does it mean for a classifier to be calibrated? Compute the expected calibration error (ECE) for two confidence bins: 60 predictions with mean confidence 0.9 and accuracy 0.75, and 40 predictions with mean confidence 0.6 and accuracy 0.55. How does temperature scaling fix miscalibration?