Module 5 · Data that arrives dirty

Leakage: when a feature knows the future

In this lesson

  • 10 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 11 of 12 in this chapter

This chapter’s goalLoad an exported CSV with mixed encodings, ambiguous dates and duplicate rows into a typed, deduplicated table by re-runnable query with every dropped row counted, decide and document what each missing value means, and produce a feature table for a model in which no column knows anything that happened after its row’s timestamp.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available
The same four features, written twiceKnows the futuresum(amount) over every order the customer everplacedcustomers.segment, which last night’s job setto ‘lapsed’A city’s churn rate whose average includesthis row’s own labelJanuary and February snapshots of onecustomer, split across training and testKnows only the pastsum(amount) where placed_at is strictly beforeas_ofThe segment that was true on as_of, from ahistory tableThe rate over training rows only, with thisrow subtracted outA split by customer, or by time with everytraining snapshot firstA feature with an almost perfect correlation with the label is a leak until proved otherwise; realsignals are weaker than that. A timestamp check finds the first two of these. The other two are foundby a person who knows which process writes each column, and when.
A feature with an almost perfect correlation with the label is a leak until proved otherwise; real signals are weaker than that. A timestamp check finds the first two of these. The other two are found by a person who knows which process writes each column, and when.

Figure

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

The model that scored 99% and failed on Monday

A churn model is trained, evaluated on held-out rows, and reports 0.99 accuracy. It goes live and predicts almost nothing useful. Nothing in the model is broken. One of its features contained the answer, in a form that was available in the training table and is not available on the day a prediction is needed. That is leakage, and in tabular work it almost always enters through a join or an aggregate in the feature query.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Building Apps with AI exam.

Stuck on something?Ask Divya, your AI tutor

How to cite: Addaly (2026) ‘Leakage: when a feature knows the future’, in Data, SQL and Getting to the Answer. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/data-and-sql/leakage-in-a-join (Accessed: 29 November 2026).