Skip to content

Scaling the full history

Question

You standardise all historical feature rows before splitting into train and test periods. Why can this leak information even without using labels?

Short answer

The means and variances encode information about the future feature distribution. A live model would not have had those statistics at the historical fitting date. Fit the scaler separately within each training fold and transform the corresponding validation or test set with those fitted values. An online update can be valid, but its timing must reproduce what would have been available live.

Original question and answer written by SelfMadeQuant.com.

See the hint and the full worked solution in the question bank (free account).

Open the worked solution

Lessons behind this question