A churn model includes a cancellation reason field that employees fill in only after a customer has already left. The model scores very well in testing and poorly once it runs in production.
Target leakage is what happens when a model is trained on a feature that carries information about the outcome but would not be available at the moment the model makes a real prediction, so test results look better than the model can perform once it is in use.
Target leakage is a data problem before it is a modeling problem. In CUBIG’s definition, AI-ready data fits a specific AI task, and for a prediction task that fit depends on which data is available when the prediction is made.
In the churn example, the cancellation reason exists only because the customer already left. The model learns to read the answer from that field instead of learning the signals that come before a cancellation. A team that trusts the test score then deploys a model that cannot see the field it relied on.
Wikipedia’s Leakage (machine learning) entry states that “leakage (also known as data leakage or target leakage) refers to the use of information during model training that would not be available at prediction time.” The entry notes that leakage results in overly optimistic performance estimates, and gives examples such as including a MonthlySalary column when predicting YearlySalary.
The scikit-learn documentation on common pitfalls gives the same definition and warns that leakage produces overly optimistic estimates, for example from cross-validation. The documentation also advises that transformations should only be learnt from the training data.
How does target leakage get into training data?
- Fields filled in after the outcome, such as status codes, resolution notes or cancellation reasons.
- Proxies or duplicates of the label, such as a column that restates the outcome in another form.
- Aggregates computed over a period that includes the outcome, such as a monthly total that ends after the prediction date.
- Joins with tables that were updated after the prediction date, which bring later information into earlier records.
How is target leakage different from train-test contamination?
Wikipedia uses target leakage as another name for data leakage in general; this entry uses the narrower sense of features that would not be available at prediction time. In that sense, target leakage is about which features are available at prediction time. Train-test contamination is about test data influencing training, for example when the same records appear on both sides of the split or when a team fits a scaler or an imputation step on the full dataset before splitting it.
Both problems inflate evaluation results. A team can have one without the other, so the AI team checks the feature list and the order of preparation steps separately.
How do teams find and prevent target leakage?
- The data owner records when each field is created or updated relative to the outcome.
- The AI team builds features only from data that is available at the prediction date.
- The AI team investigates any single feature that predicts the outcome almost perfectly.
- The AI team splits data by time when the task predicts future events, and fits preprocessing on the training data only to avoid train-test contamination as well.
CUBIG’s Syntitan is an AI-ready data platform. Syntitan’s Ready for Raw Data check reviews a dataset’s condition across six axes: usability, integrity, context, consistency, reproducibility and traceability. Syntitan keeps the original dataset intact, starts each Use Case Project from a copy and records preparation and verification results as Versions, so a team can tell which version of the data it prepared and checked.
Related entries: data leakage in machine learning, train-test split and feature engineering.