FRENESDE

Machine learning: leakage and purged validation

Leakage happens when the model sees, during training, information that was not available at decision time: a feature built with future data, normalisation over the whole sample, a universe filtered with today’s survivors.
Classic k-fold cross-validation shuffles dates. Yet in finance, labels overlap: if the label is the return over the next 10 days, a training observation just before the test set shares days with it. The validation score becomes too optimistic.
Purged validation (López de Prado, 2018) removes from the training set the observations whose label window overlaps the test set (purging), then adds an embargo after the test. Example: 2,500 days, 10-day label → purge 10 days before each test block; 1% embargo = 25 days after.
The minimum: split in time order, train on the past, test on what follows, and leave a gap between them at least as long as the label (10 days here). Warning signs: 70% accuracy on daily direction, huge importance of a single feature, or a sharp drop as soon as you go live.

Examples

Key terms

Data leakage
Future or unavailable information that enters the model’s training
Label overlap
Labels computed over time windows that overlap
Purging
Removing from the training set observations whose label overlaps the test period
Embargo
Period removed right after the test to stop information spilling over
Feature
Model input variable: for example past return or volume
Label
What the model must predict: for example the sign of the 10-day return
Train and test
Data used to train the model, and separate data used to evaluate it
K-fold
Validation that splits data into k blocks: each serves as the test in turn
Take the mission on Doji Academy

← Back to the index