[MRG + 1] Complete deprecation of default average in P/R/F metrics#7304
[MRG + 1] Complete deprecation of default average in P/R/F metrics#7304ogrisel merged 4 commits intoscikit-learn:masterfrom
Conversation
Also update tests for new behaviour and ensure there are warnings for some changed and confusing (pity) behaviours.
| y_pred) | ||
|
|
||
|
|
||
| @ignore_warnings |
There was a problem hiding this comment.
Because without it there are warnings related to 0 denominators.
There was a problem hiding this comment.
Could you please add a comment to make that explicit?
|
We could allow the user to set I had hoped to get rid of |
|
I would also hope to get rid of that but that makes it harder / less obvious to do The Right Thing (tm) in the binary case. We could also say "if average='binary' then pos_label is the smaller label and if you want anything else use the labels parameter" |
|
THe problem with that strategy is that |
|
Getting rid of |
sklearn/metrics/classification.py
Outdated
| method over binary targets. | ||
| The class to report if ``average='binary'`` and the data is binary. | ||
| If the data are multiclass or multilabel, this will be ignored; | ||
| setting `labels=[pos_label]` and `average != 'binary'` will report |
There was a problem hiding this comment.
Double quote for labels=[pos_label] and average != 'binary'
3132bff to
ce3c84f
Compare
|
lgtm |
|
LGTM too :) |
|
LGTM as well. Squash-merging. |
|
Thanks a lot @jnothman! |
Supersedes #7134 (and fixes prematurely-closed #5434).
Old behaviour:
averagedefaults to 'weighted'. This was nonstandard.Noneandpos_label(default 1) is notNone, having binary data meant binary P/R/F. This was brittle.labelscould not be used to limit the label set when averaging. This was lacking.Deprecation behaviour:
averagedefaults to 'binary' but with the old semanticslabelscan be used to limit the label set when averaging.New behaviour:
averagedefaults to 'binary'.average == 'binary'with non-binary data will result in an error so that the user chooses an explicit averaging mode.average != 'binary'with binary data will result in averaging over each class inlabels.pos_labeldoes nothing when average != 'binary'. Ifpos_labelis not the default, and notNone(due to legacy behaviour), we now issue a warning saying it's unused.