Iterative imputation
In the previous exercise, you derived mean imputations for missing values of loan_data
. However, in a machine learning interview, you will probably be asked about more dynamic imputation techniques that rely on other features in the dataset.
In this exercise, you'll practice a machine-learning based approach by imputing missing values as a function of remaining features using IterativeImputer()
from sklearn.impute
. This is a multivariate imputer that estimates each feature from all of the others in a 'round-robin' fashion.
Note that this function is considered experimental, so please read the documentation for more information.
You're at the same place in the Pipeline:
This exercise is part of the course
Practicing Machine Learning Interview Questions in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Explicitly require this experimental feature
from sklearn.experimental import enable_iterative_imputer
# Now you can import normally from sklearn.impute
from sklearn.impute import IterativeImputer
# Subset numeric features: numeric_cols
numeric_cols = ____.____(____=[____.____])