Skip to main content
Module 4 · Lesson 6 of 620/56 in the course~22 min
Module lessons (6/6)

Data leakage

Lesson preview6 hands-on exercises readyMachine Learning: from first principles to practice · Module 4 — Generalization and evaluation

How information leaks into training, and how pipelines prevent it.

What you'll learn in this lesson

  • Recognise the main forms of data leakage.
  • Fit preprocessing on the training data only.
  • Use a Pipeline so cross-validation cannot leak.

Overview

A model scores 99% in testing and collapses in production. Often the cause is data leakage: information that would not be available at prediction time slipped into training, so the evaluation was secretly easy. It is the most common way for careful people to fool themselves.

Compare leaky global scaling against clean fold-by-fold Pipeline cross-validation below:

Sections covered in this lesson

  1. 1The hook: too good to be true
  2. 2Three common leaks
  3. 3Try it: interactive leakage & pipeline simulator
  4. 4Progressive examples: catching and preventing leaks
  5. 5The cure: put preprocessing inside a pipeline
  6. 6Practice
Pro Lesson · Module 4 — Generalization and evaluation

Unlock "Data leakage" and the full Machine Learning: from first principles to practice curriculum

How information leaks into training, and how pipelines prevent it.

Unlock all 6 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Machine Learning: from first principles to practice plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.