Skip to main content
New research note:Parameter Sensitivity: Look for Plateaus, Not Peaks
Validraft
Leakage

Preprocessing Leakage: When the Scaler Has Seen the Future

Normalizing a feature with statistics from the whole history quietly gives every past decision a view of later data.

3 min readResearch and simulation only
Feature engineeringLeakageCross-validation
Flour being sifted through a fine metal sieve.
Photo (cropped and colour-graded): Shixart1985 · CC BY 2.0 · source
In this note

Working definition

Preprocessing leakage occurs when a transformation applied to the inputs, such as scaling, clipping, imputation or feature selection, is estimated with data that would not have been available at the time of each decision.

01

The leak hides in a convenience step

Consider a hypothetical signal built from a z-score of a valuation ratio. The researcher computes the mean and standard deviation over 2010 to 2026, standardizes the whole column, and then runs a walk-forward test on the result. Every observation from 2012 is now expressed relative to a distribution that includes 2020 and 2024. The walk-forward split looks clean, but the input it splits was built with the full history. This is an illustrative example, not a result from a Validraft client strategy.

The effect is not limited to scaling. Clipping at full-sample percentiles, filling missing values with a column median, or choosing the features that correlate best with returns over the whole period all carry information backwards in time. scikit-learn's guidance on common pitfalls states the general rule: transformations should be learnt from the training data only, and fitting on all of the data can produce overly optimistic scores.

02

Fit inside the window, apply forward

The remedy is procedural. Each transformation is estimated using only the data inside the training window, frozen, and then applied to the following test window. In a rolling or expanding design, that means recomputing the statistics at every refit. A pipeline that bundles preprocessing with the model makes this harder to get wrong, because each refit then re-estimates the whole chain.

Time-ordered splits are necessary but not sufficient. A time-series splitter keeps training folds ahead of test folds and can leave a gap between them; it does nothing about a column that was normalized before the split. The review question is where each statistic was computed, not only how the rows were divided.

  • Record the window used to estimate every scaling, clipping, imputation and selection step.
  • Refit those steps on the same schedule as the model at each walk-forward refit.
  • Leave a gap between training and test windows when labels or features span several periods.

03

Cross-sectional transforms have their own clock

Ranking stocks against each other on the same date is not a time leak by itself, provided the universe is the one that existed on that date. The leak returns if the cross-section is drawn from today's constituents, or if a sector-neutralization step uses classifications assigned later. Cross-sectional steps inherit the point-in-time quality of the universe and reference data behind them.

A practical diagnostic is to rerun the study with every transformation fitted strictly in-window and compare. A large change does not prove that the original was wrong, but it identifies which conclusions depended on information from the future and should be reported as such.

Practical takeaways

  • A clean time split does not protect a feature that was transformed with full-sample statistics.
  • Estimate each preprocessing step inside the training window and apply it forward.
  • Cross-sectional ranks are only as point-in-time as the universe and reference data they use.
  • Compare in-window and full-sample preprocessing to locate conclusions that depend on the leak.

Want an independent read?

Test the claim, the data, and the implementation together.

Validraft scopes the hypothesis, checks feasibility, and delivers a descriptive validation report with visible evidence and limitations. Research and simulation only; never investment advice.