Aan de slagGa gratis aan de slag

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:

Machine learning pipeline

Deze oefening maakt deel uit van de cursus

Practicing Machine Learning Interview Questions in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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 = ____.____(____=[____.____])
Code bewerken en uitvoeren