Purging and Embargo
Also known as: embargo period, gap between train and test.
Removing training observations whose time span overlaps the test period, and skipping a short stretch after it, so no information leaks between the two.
Synthetic dataExamples on this page use synthetic data created for illustration.
Not adviceThis is educational material. It is not investment, business or other professional advice.
Definition
Purging removes from the training data every observation whose time span overlaps the test period; an embargo additionally skips a short stretch of data right after the test period. Both stop information leaking between training and test sets when observations overlap in time.
In plain terms
Many labels look forward: “the change over the next 5 days”. The label of an observation on day 18 is decided by days 19 to 23. If the test period starts on day 21, that training example already contains information from inside the test period, and a model trained on it has, in effect, seen part of the answer.
Purging drops the overlapping training examples. An embargo goes one step further for the data that follows the test period, because nearby observations are correlated and would otherwise carry information backwards into training.
Example
Labels use the next 5 days. The test period is days 21 to 30.
| Training example on day | Its label uses days | Overlaps the test period? | Action |
|---|---|---|---|
| 15 | 16–20 | No | Keep |
| 16 | 17–21 | Yes (day 21) | Purge |
| 20 | 21–25 | Yes | Purge |
| 31–35 (after the test) | — | Correlated with the test | Embargo (skip) |
Without purging, days 16 to 20 would put the test period’s own outcomes into the training set.
Common misunderstandings
- “A random split of time-ordered observations is safe if the features differ.” Overlapping labels and serial correlation link neighbouring observations whatever the features are.
- “Embargo and purge are the same thing.” Purging handles overlap before the test period; the embargo handles correlation after it.
- “This is only for finance.” It applies wherever labels or features span a window of time.
References
- Marcos López de Prado. Advances in Financial Machine Learning, chapter 7: Cross-Validation in Finance . Wiley, 2018. ISBN 978-1119482086.
- Jeff Racine. Consistent Cross-validatory Model-selection for Dependent Data: hv-block Cross-validation . Journal of Econometrics, 2000. DOI: 10.1016/S0304-4076(00)00030-0