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
- Measure missingness per feature and against the target.
- Compare median and KNN imputation in the pipeline.
- Add missing indicators.
- 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
-
What does add_indicator=True do?
Show answer
Adds columns showing where values were missing.
-
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.