core Estimated learning time: 6 h

3.5 Data cleaning and leakage

You can produce a dataset your model result can be trusted on.

Before:01. Mathematics for Machine Learning02. Python — Basics to AdvancedUnlocks:05. Classical Machine Learning

Cleaning decides whether a model result means anything: missing-data mechanisms, outliers, duplicates and unit errors all change conclusions when handled thoughtlessly. Leakage — future or target information sneaking into features — is the most expensive mistake in applied machine learning, and this topic treats it with the seriousness it deserves. It sits before modelling on purpose. The core rule: clean inside the training fold, never on the full dataset, or the validation score becomes a beautiful lie.

Work through these

  • Missing data: MCAR/MAR/MNAR and imputation choices

    Values can be missing for reasons unrelated to the data, related to what was observed, or related to the missing value itself, and the right repair differs in each case. Filling blindly can invent a pattern that was never there.

  • Outliers: detect, understand, then decide

    An unusual value can be an error, a rare genuine case, or the very thing you are looking for. Detecting is mechanical, understanding is not, and deciding comes last.

  • Duplicates, inconsistent categories, unit errors

    Repeated rows, the same category spelled several ways, and quantities recorded in different units. These three account for most of the mess in real datasets.

  • Target leakage and train/test contamination

    Information that would not be available at prediction time leaking into training produces a wonderful score and a useless model. This is the single most damaging mistake in applied machine learning.

Sign in to keep your progress.

Free resources

Links last checked 29 Aug 2026.

Stuck here?

Ask a mentor. A real person answers, and they can see exactly which topic you're on. Usually within a couple of working days.

Checking your session…

Topics shown in module order.