ml4t-data-leakage
Installation
SKILL.md
Data Leakage
Leakage lets test-set information influence training, producing models that look good in development but fail in production.
The Problem
Three distinct failure modes inflate backtest performance:
- Target leakage - features computed from the target variable (e.g., future returns embedded in a "sentiment score" that was derived from price changes).
- Train-test contamination - fitting a scaler, encoder, or selector on the full dataset before splitting, so test statistics leak into training transforms.
- Temporal leakage - using future data in features (overlaps with lookahead bias, but here the mechanism is the train/test split itself, not the feature formula).
A pipeline that fits a StandardScaler on the full matrix before splitting commonly inflates Sharpe by 0.2-0.5 on daily data. The model learns the test set's distribution.