Machine Learning, FoundationsLesson 28 of 92

Module 3 · The data is the job

Leakage: a catalogue of the ways the answer gets in

In this lesson

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

This chapter’s goalTake a raw table with mixed types, missing values, high-cardinality categories, dates and free text, and produce a fitted preprocessing pipeline that leaks nothing from the held-out data, handles categories unseen at training time, and whose every transformation you can justify by what the downstream model requires.

This chapter’s media

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

FormatEnglishहिंदी
Chapter filmWatch1:44Not available
Full audiobookNot availableNot available
Where each column sits against the moment of predictionDay 0Application submitted. The moment of prediction: every feature must exist now, withthe value it has now.Day 0, laterLoan disbursed. The clock on the target starts.Every nightcurrent_balance is overwritten. The training table holds today’s balance, not dayzero’s: the concept is fine, the timestamp leaks.Day 90+Ninety days past due is recorded. This is the target.Afterwardsinvestigation_opened, cancellation_reason. These are consequences of the outcome,not causes, and only rows with the outcome have them.Only values fixed at day zero, as they were on day zero, are features. current_balance is a legitimateconcept with a leaking timestamp; investigation_opened is a consequence of the target. The test forevery column is the same question: what is its value at the moment of prediction, for a row whoseoutcome is not yet known?
Only values fixed at day zero, as they were on day zero, are features. current_balance is a legitimate concept with a leaking timestamp; investigation_opened is a consequence of the target. The test for every column is the same question: what is its value at the moment of prediction, for a row whose outcome is not yet known?

Figure

A little at a time

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

Step 1 of 9Free · no account needed
Lesson steps

The definition that covers every case

Leakage is any information in your training features that will not be available, in that form, at the moment you have to make a real prediction.

It is the most expensive error in applied machine learning because it does not look like an error. It looks like success. Your score goes up, your cross-validation agrees, your colleagues are impressed, and the model fails the day it meets production.

The signature is worth memorising: a result substantially better than you expected, arriving with no effort. Every experienced practitioner has learned to distrust that feeling, and the check takes fifteen minutes.

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 How a Language Model Actually Works exam.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘Leakage: a catalogue of the ways the answer gets in’, in Machine Learning, Foundations. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/machine-learning-foundations/leakage-in-detail (Accessed: 29 November 2026).