Skip to content

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

Merged
glemaitre merged 37 commits into
scikit-learn:mainfrom
glemaitre:is/15880_confusion_matrix
Jan 22, 2021
Merged

glemaitre merged 37 commits into
scikit-learn:mainfrom
glemaitre:is/15880_confusion_matrix

Conversation

@glemaitre

@glemaitre glemaitre commented Oct 6, 2020 •

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@NicolasHug NicolasHug left a comment

Copy link
Copy Markdown
Member

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

Comment thread doc/whats_new/v0.24.rst Resolved
Comment thread sklearn/utils/tests/test_docstring.py Resolved
Comment thread sklearn/utils/_docstring.py Resolved
@@ -0,0 +1,328 @@
from numpy.testing import (

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread sklearn/utils/_docstring.py Resolved

@NicolasHug NicolasHug left a comment

Copy link
Copy Markdown
Member

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!

@glemaitre

Copy link
Copy Markdown
Member Author

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

@glemaitre

glemaitre commented Oct 17, 2020 via email

Copy link
Copy Markdown
Member Author

@glemaitre glemaitre removed the Needs Decision Requires decision label Oct 17, 2020
@glemaitre

Copy link
Copy Markdown
Member Author

@adrinjalali Do you think that we can go forward?

@adrinjalali adrinjalali left a comment

Copy link
Copy Markdown
Member

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 :)

@thomasjpfan thomasjpfan left a comment

Copy link
Copy Markdown
Member

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

Comment thread doc/whats_new/v0.24.rst Resolved
@glemaitre

Copy link
Copy Markdown
Member Author

ping @adrinjalali Would it be fine to go ahead.

@adrinjalali adrinjalali left a comment

Copy link
Copy Markdown
Member

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 :)

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
Copy Markdown
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