Machine Learning (ML) · Intermediate level

Intermediate level · Module 5: Imbalanced and Messy Real-World Data · Lesson 2 of 3

Missing Data Strategies

Choose and compare imputation strategies, and use the fact that data is missing as information.

In this lesson you will

  • Compare simple and model-based imputation
  • Add missingness indicators where missingness is informative

Key concepts

SimpleImputerKNNImputer and IterativeImputermissing indicatorwhy data is missing

The lesson

Why data is missing matters. A missing value may be random, or it may mean something — an agent who did not report may be the one in trouble.

SimpleImputer fills with mean, median or most frequent values; KNNImputer and IterativeImputer use other features to estimate missing values. Put imputers inside the pipeline.

add_indicator=True adds a column marking where values were missing, letting the model use that signal. Compare strategies with cross-validation rather than assuming the most complex is best.

Step by step

  1. Measure missingness per feature and against the target.
  2. Compare median and KNN imputation in the pipeline.
  3. Add missing indicators.
  4. Choose the strategy with the best cross-validated score.

Practice activity

Report which imputation strategy works best for the agent data and why.

Expected result: A cross-validated comparison and an explanation linked to why data is missing.

Check your understanding

  1. What does add_indicator=True do?

    Show answer

    Adds columns showing where values were missing.

  2. Why might missing data be informative?

    Show answer

    The reason for missingness can be related to the outcome.

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.