DOC Improve pos_label and labels in precison/recall/f1 and jaccard#27714
Merged
glemaitre merged 5 commits intoscikit-learn:mainfrom Nov 4, 2023
Merged
DOC Improve pos_label and labels in precison/recall/f1 and jaccard#27714glemaitre merged 5 commits intoscikit-learn:mainfrom
pos_label and labels in precison/recall/f1 and jaccard#27714glemaitre merged 5 commits intoscikit-learn:mainfrom
Conversation
Member
Author
|
cc @glemaitre |
glemaitre
approved these changes
Nov 3, 2023
sklearn/metrics/_classification.py
Outdated
| Jaccard similarity coefficient for `pos_label`. If `average` is not `'binary'`, | ||
| `pos_label` is ignored and scores for both classes are calculated, and averaged or | ||
| both returned (when `average=None`). Similarly, for :term:`multiclass` and | ||
| :term:`multilabel` targets, scores for all `labels` can be returned or use |
Member
There was a problem hiding this comment.
It would be nice to remove "can be"
Member
Author
There was a problem hiding this comment.
I've amended to not include "can be", hopefully it is better.
sklearn/metrics/_classification.py
Outdated
| and F1 score for both classes are calculated and averaged or both returned (when | ||
| `average=None`). Similarly, for :term:`multiclass` and :term:`multilabel` targets, | ||
| F1 score for all `labels` can be returned or use `average` to specify the averaging | ||
| technique to be used. Use `labels` specify the labels to calculate F1 score for. |
Member
There was a problem hiding this comment.
I am always wondering if it is more natural to say "compute" or "calculate" :) (you can change depending what you like better here and in other places)
sklearn/metrics/_classification.py
Outdated
| label. For the :term:`binary` case, setting `average='binary'` will return | ||
| metrics for `pos_label`. If `average` is not `'binary'`, `pos_label` is ignored | ||
| and metrics for both classes are calculated, and averaged or both returned (when | ||
| `average=None`).Similarly, for :term:`multiclass` and :term:`multilabel` targets, |
Member
There was a problem hiding this comment.
Suggested change
| `average=None`).Similarly, for :term:`multiclass` and :term:`multilabel` targets, | |
| `average=None`). Similarly, for :term:`multiclass` and :term:`multilabel` targets, |
glemaitre
approved these changes
Nov 3, 2023
Member
glemaitre
left a comment
There was a problem hiding this comment.
It looks much better @lucyleeow.
Member
|
Going to merge this one since this is a DOC PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reference Issues/PRs
Towards #10010 - removal of
pos_label=Noneas it is ill-defined and inconsistently implemented.What does this implement/fix? Explain your changes.
Documention of
pos_labels=Noneinprecision_recall_fscore_supportseems to have been removed in this commit. Prior to v0.18 you needed to setpos_label=Noneif targets were binary but you wanted to useaverage != 'binary'(ref). Nowpos_labelis just ignored ifaverage != 'binary', so you no longer need to worry about settingpos_labelto any specific value. (The related functionsf1_score/fbeta_score/precision_score/recall_scorebehave the same)History of the similar
jaccard_scorewas more difficult to track.pos_labelwas added in #13151 but there was never any mention ofNoneoption.Implementation wise, all these functions will allow
pos_label=None.pos_labelis only used ifaverage='binary'and in this casepos_label=Nonewill raise an error.This PR:
Noneaspos_labeloption inf1_scoredocstring (the only function that still hadNonein its docstring)pos_label=Noneinprecision_recall_fscore_supportdocstring:scikit-learn/sklearn/metrics/_classification.py
Lines 1580 to 1582 in fb6b9f5
and add clarifications about
pos_labelandlabelsparams.pos_labelandlabelsexplanation to the other 5 functions as welllabelsparam doc:scikit-learn/sklearn/metrics/_classification.py
Lines 1609 to 1612 in 2fcf181
Looking at the commit this was added, the related addition to
model_evaluation.rstseems to expand what the docstring above means so I've used this to clarify.Any other comments?
tl;dr update
pos_labelandlabelsexplanations in docstrings of the following 6 functions:precision_recall_fscore_support/f1_score/fbeta_score/precision_score/recall_scorejaccard_score