Basic Prerequisites: Probability & Measure Theory and Backtesting Hygiene (the Deflated Sharpe Ratio, PBO (probability of backtest overfitting), multiple testing). Comfort with Feature Engineering & Labeling (interval labels) is what makes the purge meaningful. (these are the folder-level prerequisites for pages 02–06; page 01 states its own, smaller, entry requirements)
1. Intuition & Practical Objective
Every ML evaluation in finance is an act of leakage control. A standard -fold cross-validation (CV) splits an IID dataset into train and test and shuffles so that “no observation leaks into another set.” But financial observations are not IID: features are serially correlated () and, because labels are formed over overlapping forward windows (e.g., “sign of the next -bar return”), adjacent labels are near-duplicates (). Put in the training set and in the test set and you have just told the model the answer.
This folder is the topic-hub for purged cross-validation and backtest hygiene in Kwant-Atlas, the companion to the classical backtesting-hygiene folder (multiple testing, DSR) but for the ML pipeline. It (a) gives the fast formula/decision lookup below - job #1 of a hub - and (b) routes you to six sub-pages that go from raw intuition through the two leak-removal tools (purging, embargoing), their combinatorial generalization (CPCV), and the failure modes and practice.
The one-sentence essence. “Standard -fold CV measures skill plus leaked duplicate labels; purging drops every training observation whose label window overlaps the test set, an embargo drops the serially-correlated stragglers right after it, and Combinatorial Purged CV (CPCV) repeats the honest split across every test-set combination to yield a distribution of backtest paths instead of one fragile number.”
2. Mathematical Ground Truth & Derivations
Quick-Reference Lookup (job #1). Notation: label of observation spans the closed bar interval ; test block spans ; = number of observations, = number of contiguous groups, = number of groups in the test set, = embargo length in bars, = number of backtest paths. All checks below were re-executed and reproduced exactly (see §3).
| Quantity | Formula | Verified check |
|---|---|---|
| Purge condition (drop train if label overlaps test - any of 3) | · · | all three = overlap purge |
| Embargo (kill post-test serial memory) | re-label test as , then purge; suffices | |
| Number of train/test splits (test of groups) | ||
| Number of backtest paths | ; ; | |
| Fraction of data used for training per combination | ||
| Max paths (limit) | ||
| CPCV variance of sample-mean Sharpe | , |
Critical caveat (AFML §12.4.3). There is a strict budget: more paths requires either more groups (smaller group granularity) or a bigger test fraction - and the latter shrinks the training data (). The practical sweet spot is with , which trains on of the data while still yielding paths. Pushing to maximizes but trains each classifier on only half the sample.
3. Computational Implementation - the hygiene engine
Standard-library only. This reproduces the two headline numbers in §2: the leakage signature (accuracy inflates with the number of folds on a pure-noise feature) and the CPCV path counter.
Read it as the punchline of the whole folder: on pure noise, thinning the folds from block- to leave-one-out drives standard CV accuracy from to - a textbook “false discovery” manufactured purely by leaked overlapping labels. Purging pins every configuration at . The same classifier sees no signal.
4. Failure Modes & First-Principles Breakdowns
Hub signposts - the practice checklist lives in 05 · Failure Modes & Practice. In one line each:
- Look-ahead (label) leakage - overlapping label windows make adjacent train/test samples near-duplicates; standard CV reads the answer back (02).
- Purging is not free - dropping overlapping training rows shrinks the sample, and the loss grows with the label horizon (up to at ); a real bias–variance tradeoff (05).
- One path = one lottery ticket - walk-forward and CV each produce a single backtest, so their Sharpe is a high-variance draw; CPCV replaces it with a distribution (04).
- The missing again - a purged CV that is run a thousand times still suffers selection bias; pair it with the Deflated Sharpe Ratio (Backtesting Hygiene).
5. References
- López de Prado, Marcos: Advances in Financial Machine Learning (Wiley, 2018)
- Bailey, Borwein, López de Prado & Zhu: The Probability of Backtest Overfitting, J. Computational Finance 20(4) (2017)
- Bailey & López de Prado: The Deflated Sharpe Ratio, J. Portfolio Management 40(5) (2014)
- Hastie, Tibshirani & Friedman: The Elements of Statistical Learning (2nd ed., 2009)
- “Backtest Overfitting in the Machine Learning Era” (Expert Systems with Applications, 2025)
6. Connected Graph Bridges
- Foundational base: Probability & Measure Theory · Backtesting Hygiene (classical: DSR, PBO, multiple testing)
- Sibling (same pillar): Tree-Based Factor Ranking & Purged CV (purging applied to LightGBM/XGBoost MDA) · Financial ML Pitfalls & Low SNR
- Labels that need purging: Feature Engineering & Labeling (triple-barrier & interval labels)
- Sub-pages (in-folder): 01 From Zero · 02 Why Standard CV Fails · 03 Purging & Embargo · 04 Combinatorial Purged CV · 05 Failure Modes · 06 Advanced Extensions