8000 ENH Add warning when only one label found in `confusion_matrix` by lucyleeow · Pull Request #27650 · scikit-learn/scikit-learn · GitHub 8000
[go: up one dir, main page]

Skip to content

Conversation

@lucyleeow
Copy link
Member

Reference Issues/PRs

fixes #19756

What does this implement/fix? Explain your changes.

Add warning when only one label found in confusion_matrix and advise user to pass all labels via labels parameter.

@github-actions
Copy link
github-actions bot commented Oct 24, 2023

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 33fe2a0. Link to the linter CI: here

@lucyleeow lucyleeow added the Quick Review For PRs that are quick to review label Oct 24, 2023
if cm.shape == (1, 1):
warnings.warn(
(
"Only one label was found in 'y_true' and 'y_pred', use the 'labels' "
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"Only one label was found in 'y_true' and 'y_pred', use the 'labels' "
"A single label is found in 'y_true' and 'y_pred', use the 'labels' "

Copy link
Member Author

Choose a reason for hiding this comment

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

This is nicer!

Copy link
Member
@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

Could you also add an entry in the changelog and a non-regression test?
Per the discussion, the resolution is fine to me.
Thanks @lucyleeow

@glemaitre glemaitre changed the title Add warning when only one label found in confusion_matrix ENH Add warning when only one label found in confusion_matrix Oct 30, 2023
@lucyleeow
Copy link
Member Author

Done thank you @glemaitre !

Copy link
Member
@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @lucyleeow

@glemaitre glemaitre added the Waiting for Second Reviewer First reviewer is done, need a second one! label Oct 31, 2023
Copy link
Contributor
@OmarManzoor OmarManzoor left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @lucyleeow

@OmarManzoor OmarManzoor merged commit 2fcf181 into scikit-learn:main Nov 3, 2023
@lucyleeow lucyleeow deleted the cm_warn branch November 3, 2023 09:49
REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:metrics Quick Review For PRs that are quick to review Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confusion Matrix is of wrong shape

3 participants

0