MICE imputation
The fancyimpute
package offers various robust machine learning models for imputing missing values. You can explore the complete list of imputers from the detailed documentation. Here, we will use IterativeImputer
or popularly called MICE for imputing missing values.
The IterativeImputer
performs multiple regressions on random samples of the data and aggregates for imputing the missing values. You will use the diabetes
DataFrame for performing this imputation.
This is a part of the course
“Dealing with Missing Data in Python”
Exercise instructions
- Import
IterativeImputer
fromfancyimpute
. - Copy
diabetes
todiabetes_mice_imputed
. - Create an
IterativeImputer()
object and assign it tomice_imputer
. - Impute the
diabetes_mice_imputed
DataFrame.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import IterativeImputer from fancyimpute
___
# Copy diabetes to diabetes_mice_imputed
diabetes_mice_imputed = ___
# Initialize IterativeImputer
mice_imputer = ___
# Impute using fit_tranform on diabetes_mice_imputed
diabetes_mice_imputed.iloc[:, :] = ___