scikit-learn/examples/impute/plot_missing_values.py

291 lines
9.5 KiB
Python
Raw Normal View History

2013-07-09 17:12:17 +08:00
"""
====================================================
2013-07-09 17:12:17 +08:00
Imputing missing values before building an estimator
====================================================
2013-07-09 17:12:17 +08:00
2013-07-28 15:03:56 +08:00
Missing values can be replaced by the mean, the median or the most frequent
value using the basic :class:`~sklearn.impute.SimpleImputer`.
2013-07-09 17:12:17 +08:00
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
In this example we will investigate different imputation techniques:
2019-09-04 07:08:59 +08:00
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
- imputation by the constant value 0
- imputation by the mean value of each feature combined with a missing-ness
indicator auxiliary variable
- k nearest neighbor imputation
- iterative imputation
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
:class:`~sklearn.ensemble.RandomForestRegressor` on the full original dataset
is then compared the performance on the altered datasets with the artificially
missing values imputed using different techniques.
2013-07-09 17:12:17 +08:00
"""
print(__doc__)
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# Authors: Maria Telenczuk <https://github.com/maikia>
# License: BSD 3 clause
# %%
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# Download the data and make missing values sets
################################################
#
# First we download the two datasets. Diabetes dataset is shipped with
# scikit-learn. It has 442 entries, each with 10 features. California Housing
# dataset is much larger with 20640 entries and 8 features. It needs to be
# downloaded. We will only use the first 400 entries for the sake of speeding
# up the calculations but feel free to use the whole dataset.
#
2013-07-09 17:12:17 +08:00
import numpy as np
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
from sklearn.datasets import fetch_california_housing
from sklearn.datasets import load_diabetes
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
rng = np.random.RandomState(42)
X_diabetes, y_diabetes = load_diabetes(return_X_y=True)
X_california, y_california = fetch_california_housing(return_X_y=True)
X_california = X_california[:400]
y_california = y_california[:400]
def add_missing_values(X_full, y_full):
n_samples, n_features = X_full.shape
# Add missing values in 75% of the lines
missing_rate = 0.75
n_missing_samples = int(n_samples * missing_rate)
missing_samples = np.zeros(n_samples, dtype=bool)
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
missing_samples[: n_missing_samples] = True
rng.shuffle(missing_samples)
missing_features = rng.randint(0, n_features, n_missing_samples)
X_missing = X_full.copy()
X_missing[missing_samples, missing_features] = np.nan
y_missing = y_full.copy()
return X_missing, y_missing
X_miss_california, y_miss_california = add_missing_values(
X_california, y_california)
X_miss_diabetes, y_miss_diabetes = add_missing_values(
X_diabetes, y_diabetes)
# %%
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# Impute the missing data and score
# #################################
# Now we will write a function which will score the results on the differently
# imputed data. Let's look at each imputer separately:
#
rng = np.random.RandomState(0)
2013-07-09 17:12:17 +08:00
from sklearn.ensemble import RandomForestRegressor
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# To use the experimental IterativeImputer, we need to explicitly ask for it:
from sklearn.experimental import enable_iterative_imputer # noqa
from sklearn.impute import SimpleImputer, KNNImputer, IterativeImputer
from sklearn.model_selection import cross_val_score
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
from sklearn.pipeline import make_pipeline
2013-07-09 17:12:17 +08:00
N_SPLITS = 5
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
regressor = RandomForestRegressor(random_state=0)
# %%
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# Missing information
# -------------------
# In addition to imputing the missing values, the imputers have an
# `add_indicator` parameter that marks the values that were missing, which
# might carry some information.
#
def get_scores_for_imputer(imputer, X_missing, y_missing):
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
estimator = make_pipeline(imputer, regressor)
impute_scores = cross_val_score(estimator, X_missing, y_missing,
scoring='neg_mean_squared_error',
cv=N_SPLITS)
return impute_scores
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
x_labels = ['Full data',
'Zero imputation',
'Mean Imputation',
'KNN Imputation',
'Iterative Imputation']
mses_california = np.zeros(5)
stds_california = np.zeros(5)
mses_diabetes = np.zeros(5)
stds_diabetes = np.zeros(5)
# %%
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# Estimate the score
# ------------------
# First, we want to estimate the score on the original data:
#
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
def get_full_score(X_full, y_full):
full_scores = cross_val_score(regressor, X_full, y_full,
scoring='neg_mean_squared_error',
cv=N_SPLITS)
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
return full_scores.mean(), full_scores.std()
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
mses_california[0], stds_california[0] = get_full_score(X_california,
y_california)
mses_diabetes[0], stds_diabetes[0] = get_full_score(X_diabetes, y_diabetes)
# %%
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# Replace missing values by 0
# ---------------------------
#
# Now we will estimate the score on the data where the missing values are
# replaced by 0:
#
def get_impute_zero_score(X_missing, y_missing):
imputer = SimpleImputer(missing_values=np.nan, add_indicator=True,
strategy='constant', fill_value=0)
zero_impute_scores = get_scores_for_imputer(imputer, X_missing, y_missing)
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
return zero_impute_scores.mean(), zero_impute_scores.std()
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
mses_california[1], stds_california[1] = get_impute_zero_score(
X_miss_california, y_miss_california)
mses_diabetes[1], stds_diabetes[1] = get_impute_zero_score(X_miss_diabetes,
y_miss_diabetes)
# %%
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# kNN-imputation of the missing values
# ------------------------------------
#
# :class:`~sklearn.impute.KNNImputer` imputes missing values using the weighted
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# or unweighted mean of the desired number of nearest neighbors.
def get_impute_knn_score(X_missing, y_missing):
imputer = KNNImputer(missing_values=np.nan, add_indicator=True)
2019-09-04 07:08:59 +08:00
knn_impute_scores = get_scores_for_imputer(imputer, X_missing, y_missing)
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
return knn_impute_scores.mean(), knn_impute_scores.std()
2019-09-04 07:08:59 +08:00
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
mses_california[2], stds_california[2] = get_impute_knn_score(
X_miss_california, y_miss_california)
mses_diabetes[2], stds_diabetes[2] = get_impute_knn_score(X_miss_diabetes,
y_miss_diabetes)
# %%
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# Impute missing values with mean
# -------------------------------
#
def get_impute_mean(X_missing, y_missing):
imputer = SimpleImputer(missing_values=np.nan, strategy="mean",
add_indicator=True)
mean_impute_scores = get_scores_for_imputer(imputer, X_missing, y_missing)
return mean_impute_scores.mean(), mean_impute_scores.std()
mses_california[3], stds_california[3] = get_impute_mean(X_miss_california,
y_miss_california)
mses_diabetes[3], stds_diabetes[3] = get_impute_mean(X_miss_diabetes,
y_miss_diabetes)
# %%
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# Iterative imputation of the missing values
# ------------------------------------------
#
# Another option is the :class:`~sklearn.impute.IterativeImputer`. This uses
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# round-robin linear regression, modeling each feature with missing values as a
# function of other features, in turn.
# The version implemented assumes Gaussian (output) variables. If your features
# are obviously non-normal, consider transforming them to look more normal
# to potentially improve performance.
#
def get_impute_iterative(X_missing, y_missing):
imputer = IterativeImputer(missing_values=np.nan, add_indicator=True,
random_state=0, n_nearest_features=5,
sample_posterior=True)
iterative_impute_scores = get_scores_for_imputer(imputer,
X_missing,
y_missing)
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
return iterative_impute_scores.mean(), iterative_impute_scores.std()
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
mses_california[4], stds_california[4] = get_impute_iterative(
X_miss_california, y_miss_california)
mses_diabetes[4], stds_diabetes[4] = get_impute_iterative(X_miss_diabetes,
y_miss_diabetes)
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
mses_diabetes = mses_diabetes * -1
mses_california = mses_california * -1
# %%
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# Plot the results
# ################
#
# Finally we are going to visualize the score:
#
import matplotlib.pyplot as plt
n_bars = len(mses_diabetes)
xval = np.arange(n_bars)
2019-09-04 07:08:59 +08:00
colors = ['r', 'g', 'b', 'orange', 'black']
# plot diabetes results
plt.figure(figsize=(12, 6))
ax1 = plt.subplot(121)
for j in xval:
ax1.barh(j, mses_diabetes[j], xerr=stds_diabetes[j],
color=colors[j], alpha=0.6, align='center')
ax1.set_title('Imputation Techniques with Diabetes Data')
ax1.set_xlim(left=np.min(mses_diabetes) * 0.9,
right=np.max(mses_diabetes) * 1.1)
ax1.set_yticks(xval)
ax1.set_xlabel('MSE')
ax1.invert_yaxis()
ax1.set_yticklabels(x_labels)
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# plot california dataset results
ax2 = plt.subplot(122)
for j in xval:
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
ax2.barh(j, mses_california[j], xerr=stds_california[j],
color=colors[j], alpha=0.6, align='center')
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
ax2.set_title('Imputation Techniques with California Data')
ax2.set_yticks(xval)
ax2.set_xlabel('MSE')
ax2.invert_yaxis()
ax2.set_yticklabels([''] * n_bars)
plt.show()
DOC Exchanging Boston for california dataset in plot missing values (#16513) * first few comments * added new california dataset * removed boston dataset from the file * updating the DOCs * adding a DOC for calculating the error * exchanged the order started writing functions on scoring the imputers * finished writing functions for imputers * finished writing functions and started on DOcs * working on the DOCs for imputers * cleaning up * flake8 * cleaning up * cleaning up * restructuring the document * further text restructuring * text restructuring * flake8 * reformatting * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Olivier Grisel <olivier.grisel@ensta.org> * updated the intro * improve bullet point rendering * spelling * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changed the naming * restructuring text * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * changing missing values from 0 to nan * Update examples/impute/plot_missing_values.py Co-Authored-By: Alexandre Gramfort <alexandre.gramfort@m4x.org> * REGRESSOR to regressor * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Lucy Liu <jliu176@gmail.com> * flake8 * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * Update examples/impute/plot_missing_values.py Co-Authored-By: Thomas J Fan <thomasjpfan@gmail.com> * flake8 * reducting number of samples used from california dataset * CLN Removes the need for MissingIndicator * FIX Unrelated bug but is stopping the CI from passing Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org> Co-authored-by: Alexandre Gramfort <alexandre.gramfort@m4x.org> Co-authored-by: Lucy Liu <jliu176@gmail.com> Co-authored-by: Thomas J Fan <thomasjpfan@gmail.com>
2020-04-28 08:25:24 +08:00
# You can also try different techniques. For instance, the median is a more
# robust estimator for data with high magnitude variables which could dominate
# results (otherwise known as a 'long tail').