Imputing missing values before building an estimator
Missing values can be replaced by the mean, the median or the most frequent
value using the basic SimpleImputer.
In this example we will investigate different imputation techniques:
imputation by the constant value 0
imputation by the mean value of each feature
k nearest neighbor imputation
iterative imputation
In all the cases, for each feature, we add a new feature indicating the missingness.
We will use two datasets: Diabetes dataset which consists of 10 feature variables collected from diabetes patients with an aim to predict disease progression and California housing dataset for which the target is the median house value for California districts.
As neither of these datasets have missing values, we will remove some
values to create new versions with artificially missing data. The performance
of
on the full original dataset
is then compared the performance on the altered datasets with the artificially
missing values imputed using different techniques.
