The Most Overlooked Problem With Imputing Missing Values Using Zero (or Mean)

...and here's what you should try instead.

Replacing (imputing) missing values with mean or zero or any other fixed value:

  • alters summary statistics

  • changes the distribution

  • inflates the presence of a specific value

This can lead to:

  • inaccurate modeling

  • incorrect conclusions, and more.

Instead, always try to impute missing values with more precision.

kNN imputer is often a great choice if your data is missing at random (MAR).

It imputes missing values using the k-Nearest Neighbors algorithm.

Missing features are imputed by running a kNN on non-missing feature values.

The following depicts how it works:

  • Step 1: Select a row (r) with a missing value.

  • Step 2: Find its k nearest neighbors using the non-missing feature values.

  • Step 3: Impute the missing feature of the row (r) using the corresponding non-missing values of k nearest neighbor rows.

  • Step 4: Repeat for all rows with missing values.

Its effectiveness over Mean/Zero imputation is evident from the image below.

  • Mean/Zero alters the summary statistics and distribution.

  • kNN imputer preserves them.

Get started with kNN imputer: Sklearn Docs.

👉 Over to you: What are some other better ways to impute missing values?

👉 If you liked this post, don’t forget to leave a like ❤️. It helps more people discover this newsletter on Substack and tells me that you appreciate reading these daily insights.

The button is located towards the bottom of this email.

Thanks for reading!

Latest full articles

If you’re not a full subscriber, here’s what you missed last month:

To receive all full articles and support the Daily Dose of Data Science, consider subscribing:

👉 Tell the world what makes this newsletter special for you by leaving a review here :)

👉 If you love reading this newsletter, feel free to share it with friends!

Reply

or to participate.