Time series and forecasting · insight-0237
Fit normalisation statistics at each cutoff, never on the full time series
- Evidence type
- documented fact
- Difficulty
- easy
- Roles
- Data scientist, ML engineer
- Industries
- cross-industry
Summary: situation, action, reason, boundary
Situation
A notebook standardises the whole series with its mean and standard deviation, then runs a rolling-origin backtest.
Action
Put scaling, imputation and any target transformation inside the per-cutoff pipeline so each origin fits them on its own training window only.
Reason
Preprocessing fitted on data that includes the test period leaks test information; for time series the leak is information from the future.
Boundary
Neural forecasters, ML forecasts with scaled inputs, PCA on sensor panels.
Symptom or risk
Every training window has seen the future mean and spread, so level shifts after the cutoff are partly anticipated and the backtest is optimistic.
Exceptions
Fixed physical transformations with no fitted parameters (unit conversion, log) carry no leak.
Trade-offs
Refitting preprocessing per cutoff costs compute; cache by cutoff.
Pitfalls
Reusing a scaler fitted in a separate exploratory notebook.
Lessons and concepts
Claims and their sources
Fitting preprocessing on the full dataset before splitting causes data leakage; preprocessing should be fitted on training data only, for example inside a Pipeline.