Evaluating Predictions in Time Order

For a future prediction task, training data and preprocessing should be limited to information available before each tested prediction time.

Source
Anbloq
Language
English
Created
Updated
Chapters
4
Reading time
1 min
In this article4 chapters
  1. Trace a weekly history
  2. Check feature arrival
  3. Ask what data would exist on the forecast date
  4. Consider features and labels near the boundary

Trace a weekly history

Use January observations to predict outcomes in February under the declared horizon. Training on March records would give the model information unavailable to a February user. See timestamps and durations.

Check feature arrival

A row timestamp can precede the time its label or another feature becomes available. Use the availability semantics when building splits. Data leakage explains the resulting risk.[1][2]

Ask what data would exist on the forecast date

A January-through-April dataset supports a forecast evaluated on April only if the fitting process uses earlier data and information already available. Shuffling dates can let later conditions inform a past forecast. See when a feature was available.

Train window: January–March
Evaluation window: April
Aggregate transformations are fit on the earlier window
Record the prediction timestamp per example

Consider features and labels near the boundary

If target construction looks into the following week, examples just before the split may need a gap or another rule. Verify feature and target timelines with representative rows.

References

  1. Gareth James et al., An Introduction to Statistical Learning ↩
  2. scikit-learn Developers, Metrics and Scoring: Quantifying the Quality of Predictions ↩