Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] ENH add normalize parameter to confusion_matrix #15625

Merged
merged 6 commits into from Nov 15, 2019

Conversation

@glemaitre
Copy link
Contributor

glemaitre commented Nov 14, 2019

Reference Issues/PRs

closes #14478

What does this implement/fix? Explain your changes.

Move the normalization normalize from plot_confusion_matrix to confusion_matrix.
I added a couple of test and handle division by zeros without raising warning.

Any other comments?

glemaitre added 2 commits Nov 14, 2019
@glemaitre

This comment has been minimized.

Copy link
Contributor Author

glemaitre commented Nov 14, 2019

@glemaitre glemaitre changed the title ENH add normalize parameter to confusion_matrix [MRG] ENH add normalize parameter to confusion_matrix Nov 14, 2019
@thomasjpfan thomasjpfan self-requested a review Nov 14, 2019
@glemaitre glemaitre added this to the 0.22 milestone Nov 14, 2019
Copy link
Contributor

NicolasHug left a comment

Looks good. I agree it makes more sense to have it in confusion_matrix rather than in the plot utility

in ``y_true`` or ``y_pred`` are used in sorted order.
sample_weight : array-like of shape (n_samples,), default=None
Sample weights.
normalize : {'true', 'pred', 'all'}, default=None
Normalizes confusion matrix over the true (rows), predicted (columns)
conditions or all the population. If None, confusion matrix will not be

This comment has been minimized.

Copy link
@NicolasHug

NicolasHug Nov 14, 2019

Contributor

what is "conditions"?

This comment has been minimized.

Copy link
@glemaitre

glemaitre Nov 14, 2019

Author Contributor

True conditions, predicted conditions. I think that it is one way to call true values and predicted values.

@@ -155,7 +155,7 @@ def plot_confusion_matrix(estimator, X, y_true, sample_weight=None,
Includes values in confusion matrix.
normalize : {'true', 'pred', 'all'}, default=None
Normalizes confusion matrix over the true (rows), predicited (columns)
Normalizes confusion matrix over the true (rows), predicted (columns)
conditions or all the population. If None, confusion matrix will not be

This comment has been minimized.

Copy link
@NicolasHug

NicolasHug Nov 14, 2019

Contributor

same here lol

This comment has been minimized.

Copy link
@glemaitre

glemaitre Nov 14, 2019

Author Contributor

I copied it from here :). Seeking a bit more, this is defined in this way on wikipedia: https://en.wikipedia.org/wiki/Confusion_matrix

sklearn/metrics/tests/test_classification.py Outdated Show resolved Hide resolved
doc/modules/model_evaluation.rst Outdated Show resolved Hide resolved
Copy link
Member

qinhanmin2014 left a comment

I'm still wondering why we need to divide the entire matrix (though I won't oppose).

@qinhanmin2014

This comment has been minimized.

Copy link
Member

qinhanmin2014 commented Nov 15, 2019

Seems that @jnothman don't like it? #14478 (comment)

@jnothman

This comment has been minimized.

Copy link
Member

jnothman commented Nov 15, 2019

@qinhanmin2014 qinhanmin2014 merged commit 080d0e5 into scikit-learn:master Nov 15, 2019
21 checks passed
21 checks passed
LGTM analysis: C/C++ No code changes detected
Details
LGTM analysis: JavaScript No code changes detected
Details
LGTM analysis: Python No new or fixed alerts
Details
ci/circleci: deploy Your tests passed on CircleCI!
Details
ci/circleci: doc Your tests passed on CircleCI!
Details
ci/circleci: doc artifact Link to 0/doc/_changed.html
Details
ci/circleci: doc-min-dependencies Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
codecov/patch 100% of diff hit (target 97.24%)
Details
codecov/project Absolute coverage decreased by -0.01% but relative coverage increased by +2.75% compared to e650a20
Details
scikit-learn.scikit-learn Build #20191114.45 succeeded
Details
scikit-learn.scikit-learn (Linting) Linting succeeded
Details
scikit-learn.scikit-learn (Linux py35_conda_openblas) Linux py35_conda_openblas succeeded
Details
scikit-learn.scikit-learn (Linux py35_ubuntu_atlas) Linux py35_ubuntu_atlas succeeded
Details
scikit-learn.scikit-learn (Linux pylatest_pip_openblas_pandas) Linux pylatest_pip_openblas_pandas succeeded
Details
scikit-learn.scikit-learn (Linux32 py35_ubuntu_atlas_32bit) Linux32 py35_ubuntu_atlas_32bit succeeded
Details
scikit-learn.scikit-learn (Linux_Runs pylatest_conda_mkl) Linux_Runs pylatest_conda_mkl succeeded
Details
scikit-learn.scikit-learn (Windows py35_pip_openblas_32bit) Windows py35_pip_openblas_32bit succeeded
Details
scikit-learn.scikit-learn (Windows py37_conda_mkl) Windows py37_conda_mkl succeeded
Details
scikit-learn.scikit-learn (macOS pylatest_conda_mkl) macOS pylatest_conda_mkl succeeded
Details
scikit-learn.scikit-learn (macOS pylatest_conda_mkl_no_openmp) macOS pylatest_conda_mkl_no_openmp succeeded
Details
adrinjalali added a commit to adrinjalali/scikit-learn that referenced this pull request Nov 18, 2019
adrinjalali added a commit to adrinjalali/scikit-learn that referenced this pull request Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.