-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG] Ensure that classification metrics support string label #2170
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
Conversation
Damn, this works well on my laptop. |
def test_classification_report_multiclass_with_string_label(): | ||
y_true, y_pred, _ = make_prediction(binary=False) | ||
|
||
y_true = y_true.astype(np.str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the bug: this produces an array of dtype='|S1'
so the labels all get truncated to a single char. I'm on it.
Ready for reviews! |
|
||
avg / total 0.62 0.61 0.56 75 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was written twice
# print classification report with label detection
expected_report = """\
precision recall f1-score support
0 0.82 0.92 0.87 25
1 0.56 0.17 0.26 30
2 0.47 0.90 0.62 20
avg / total 0.62 0.61 0.56 75
"""
expected_report = """\
precision recall f1-score support
0 0.83 0.79 0.81 24
1 0.33 0.10 0.15 31
2 0.42 0.90 0.57 20
avg / total 0.51 0.53 0.47 75
"""
The first expected report is erased by the second one.
LGTM +1 |
Should fix #1989 |
Looks good to me as well be this branch require a rebase / conflicts fix before being able to merge. |
@arjoly do you want to rebase or should I? |
I'll do it |
Also found a faulty format op in the error handling.
@amueller rebased on top of master |
fail ;) |
Hope it will good now. |
@amueller it works ;-) |
merged by rebase. Thanks a lot! |
Since most estimators accept string as input, I make sure that most metrics will do.
This pr doesn't include metrics with y_score.
This should fix #2168, #1989