FEA Add decision_threshold_curve (approach 2)
#32732
Open
+163
−40
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
Another approach for #31338 (which superseded #25639)
closes #21391
What does this implement/fix? Explain your changes.
Uses the approach suggested by @jeremiedbb (#31338 (comment)) of using re-using
confusion_matrix_at_thresholds(previously called_binary_clf_curve) to implement curve calculation - given a callable metric, calculates the metric for each threshold.I think I like this approach better:
decision_threshold_curvein line with the other curve functions we have (det_curve,precision_recall_curve,roc_curve), which all useconfusion_matrix_at_thresholds._CurveScorer_CurveScorerfrommodel_selectiontometrics#29216_CurveScorerare probably unnecessary for this function, e.g.,sign- as this is a stand alone function (vs being used inside an estimator (TunedThresholdClassifierCV), this is probably not needed the user can manipulate the output as required. Also_CurveScoreris particular in mapping thresholded labels to original classes (requiring call tounique(y)), which isn't really needed in this caseAny other comments?
Working on this also raised two questions:
sklearn/metricsmost modules have a leading_(e.g.,_regression.py). I thought this implied private module/functions?metric_per_threshold, then changed todecision_threshold_curve, since it is already in themetricmodule, the name metric was considered redundant (see FEA Implementation of "threshold-dependent metric per threshold value" curve #25639 (comment)). Is 'decision' meant to imply that this curve is meant to help with determining the threshold to use? Is term commonly used (genuine question, as I don't have the background in this area)?cc @jeremiedbb @glemaitre , and just in case you have time @StefanieSenger