Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ENH/DEP add class method and deprecate plot function for confusion matrix #18543

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

Merged
merged 37 commits into from
Jan 22, 2021

Conversation

glemaitre
Copy link
Member

@glemaitre glemaitre commented Oct 6, 2020

Reference Issues/PRs

Addess some of #15880

What does this implement/fix? Explain your changes.

Introduce 2 class methods for ConfusionMatrixDisplay and deprecate the plot_ function.

This is the first of many successive PR. It is introducing the Substitution class to inject recurrent docstring and avoid duplicating code.

Any other comments?

@glemaitre glemaitre marked this pull request as draft October 6, 2020 09:06
@thomasjpfan
Copy link
Member

@glemaitre While working on this PR, do you think that from_est and from_preds would be better because it it shorter? The whole *Display is already pretty verbose.

@glemaitre
Copy link
Member Author

@glemaitre While working on this PR, do you think that from_est and from_preds would be better because it it shorter? The whole *Display is already pretty verbose.

To be honest, I prefer the long version especially for from_estimator. I find it more explicit. One can always rename the *Display at the import with as I think.

@glemaitre glemaitre marked this pull request as ready for review October 6, 2020 17:16
@glemaitre
Copy link
Member Author

@thomasjpfan I think this is ready for being reviewed. Note that here, I did not change the visualization guideline. I think it would be best to change it at the same time as the ROC AUC display.

Here I am introducing a new utility to make docstring substitution as in matplotlib to avoid rewriting a long list of parameters. I can still revert it if it is considered as not needed. Otherwise, we might use it in other places.

@glemaitre
Copy link
Member Author

@NicolasHug @thomasjpfan @ogrisel @amueller @jnothman

We can iterate on this PR such that it gets through and it will make the other PR easier to review then.

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @glemaitre , a few minor comments but this looks good! thanks for working on this

To be honest, I prefer the long version

I agree

doc/whats_new/v0.24.rst Outdated Show resolved Hide resolved
sklearn/metrics/_plot/confusion_matrix.py Outdated Show resolved Hide resolved
sklearn/metrics/_plot/confusion_matrix.py Show resolved Hide resolved
sklearn/metrics/_plot/confusion_matrix.py Outdated Show resolved Hide resolved
sklearn/metrics/_plot/confusion_matrix.py Outdated Show resolved Hide resolved
sklearn/utils/tests/test_docstring.py Outdated Show resolved Hide resolved
sklearn/utils/_docstring.py Outdated Show resolved Hide resolved
@@ -0,0 +1,328 @@
from numpy.testing import (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same as the previous test file, with some minor adjustements, right?

Should we also test that both class methods yield the same plots? Maybe checking the confusion_matrix attribute is enough

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is the same file but I used a fixture to test both constructor. Since some of the tests already compare to the confusion_matrix function output, I don't think that we need to check further.

sklearn/metrics/_plot/confusion_matrix.py Outdated Show resolved Hide resolved
sklearn/utils/_docstring.py Outdated Show resolved Hide resolved
Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @glemaitre , some grumpy morning comments but LGTM anyway!

sklearn/metrics/_plot/confusion_matrix.py Show resolved Hide resolved
@glemaitre
Copy link
Member Author

@NicolasHug @thomasjpfan I removed the super meta-fixture :)
I agree it makes the test easier to understand and more explicit.

@glemaitre
Copy link
Member Author

glemaitre commented Oct 17, 2020 via email

@glemaitre glemaitre removed the Needs Decision Requires decision label Oct 17, 2020
@glemaitre
Copy link
Member Author

@adrinjalali Do you think that we can go forward?

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'm happy with the docstrings as they are now :)

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment on tests, otherwise LGTM

sklearn/metrics/_plot/confusion_matrix.py Outdated Show resolved Hide resolved
glemaitre and others added 2 commits November 3, 2020 10:22
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
doc/whats_new/v0.24.rst Outdated Show resolved Hide resolved
@glemaitre
Copy link
Member Author

ping @adrinjalali Would it be fine to go ahead.

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @glemaitre . I haven't checked the actual plots, otherwise looks pretty good :)

sklearn/metrics/_plot/confusion_matrix.py Outdated Show resolved Hide resolved
sklearn/metrics/_plot/confusion_matrix.py Show resolved Hide resolved
sklearn/metrics/_plot/confusion_matrix.py Outdated Show resolved Hide resolved
sklearn/metrics/_plot/confusion_matrix.py Outdated Show resolved Hide resolved
sklearn/metrics/_plot/confusion_matrix.py Show resolved Hide resolved
sklearn/metrics/_plot/tests/test_plot_confusion_matrix.py Outdated Show resolved Hide resolved
glemaitre and others added 2 commits January 20, 2021 11:16
Co-authored-by: Adrin Jalali <adrin.jalali@gmail.com>
Base automatically changed from master to main January 22, 2021 10:53
@glemaitre glemaitre merged commit 8c6a045 into scikit-learn:main Jan 22, 2021
@glemaitre
Copy link
Member Author

Merging since the CIs are green and there is 2 approvals

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.