You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Precision @ Recall K || Recall @ Precision K #20266
Doesn't precision_recall_curve already give you all the triples (precision, recall, threshold)?
#24121 might be related as it would enable a convex hull (linear interpolation) for a (monotonically) transformed version of the precision-recall curve.
Just filter the triples (precision, recall, threshold) for recall > some value.
I don't like to be the spoilsport, but I'm currently -1 for this. I would very much prefer the ability to select a threshold for predict_proba, like #4813#8614#16525.
I also agree with @lorentzenchr here.
But I think we need to have some consensus on how to decide if a given metric is worthwhile the development + maintenance. something like this coming out of #21718 would be very useful IMHO.
@scikit-learn/core-devs Is the score "precision at recall k" in scope or out of scope for scikit-learn?
This issue proposes a new score/function precision_at_recall_k returning the precision at a certain user specified recall value k. Note that precision_recall_curve already give you all the triples (precision, recall, threshold).
With metrics, it's hard to say what belongs in the core library. It's important that there are reference implementations of these things, as their ad-hoc implementation is often prone to error or introduces spurious variation. If the implementation is a fairly trivial extension of existing library functionality, it may be worth demonstrating the usage of precision_recall_curve to calculate a desired metric in an example or similar documentation. We could, for example, have an example with popular custom metrics. The benefits of this approach over having it in the library are a lower bar to acceptance of a PR change (less bikesheddng), avoiding perfecting a name, maintenance costs and need to produce something especially efficient.
Reacted by Julien Jerphanion, Adrin Jalali and joshua vogelstein
I commented here in 2021 and never followed through, sorry. Back now because I actually need this at work, picking an enforcement threshold under a fixed recall floor, repeatedly, by hand.
@lorentzenchr your -1 was in favour of threshold selection for predict_proba (#4813, #8614, #16525). That shipped in 1.5, but the constrained objectives from that work (max_precision_at_recall_constraint + constraint_value) were dropped before release — so there's still no way to express a recall-constrained objective as a scorer.
I have an implementation ready with tests and docs, same max semantics as the closed #24671. Is the Dec 2022 scope question settled? If @jnothman's docs-instead-of-metric suggestion is preferred, I'll do that version.
Activity
Onk24 commentedon Jun 20, 2021
This is an important suggestion. I would like to contribute to the solution.
scsanjay commentedon Jun 25, 2021
@Onk24 Are you still working on it? If not then I will have look at it.
Ryanglambert commentedon Jun 25, 2021
shubhraneel commentedon Aug 27, 2021
Is anyone working on this issue? If not, may I work on it?
glemaitre commentedon Sep 1, 2021
@Ryanglambert We discussed IRL with @ogrisel today and it seems that these metrics would be a good addition indeed.
Kshitij68 commentedon Oct 15, 2022
Seems like the PR #20877 is under stalled state, so I have picked up this issue.
lorentzenchr commentedon Oct 15, 2022
Doesn't
precision_recall_curvealready give you all the triples (precision, recall, threshold)?#24121 might be related as it would enable a convex hull (linear interpolation) for a (monotonically) transformed version of the precision-recall curve.
Ryanglambert commentedon Oct 15, 2022
lorentzenchr commentedon Oct 31, 2022
Just filter the triples (precision, recall, threshold) for recall > some value.
I don't like to be the spoilsport, but I'm currently -1 for this. I would very much prefer the ability to select a threshold for
predict_proba, like #4813 #8614 #16525.Kshitij68 commentedon Nov 4, 2022
I also agree with @lorentzenchr here.
But I think we need to have some consensus on how to decide if a given metric is worthwhile the development + maintenance. something like this coming out of #21718 would be very useful IMHO.
Kshitij68 commentedon Dec 27, 2022
Hi,
Is there any decision on whether to accept this feature?
lorentzenchr commentedon Dec 28, 2022
@scikit-learn/core-devs Is the score "precision at recall k" in scope or out of scope for scikit-learn?
This issue proposes a new score/function
precision_at_recall_kreturning the precision at a certain user specified recall valuek. Note thatprecision_recall_curvealready give you all the triples (precision, recall, threshold).lorentzenchr commentedon Dec 28, 2022
-1 from me as explained in my above comments.
jnothman commentedon Dec 28, 2022
With metrics, it's hard to say what belongs in the core library. It's important that there are reference implementations of these things, as their ad-hoc implementation is often prone to error or introduces spurious variation. If the implementation is a fairly trivial extension of existing library functionality, it may be worth demonstrating the usage of
precision_recall_curveto calculate a desired metric in an example or similar documentation. We could, for example, have an example with popular custom metrics. The benefits of this approach over having it in the library are a lower bar to acceptance of a PR change (less bikesheddng), avoiding perfecting a name, maintenance costs and need to produce something especially efficient.Kshitij68 commentedon Apr 28, 2023
I will decline my PR #24671 . We can re-open it once a consensus has been reached.
Onk24 commentedon Sep 18, 2026
I commented here in 2021 and never followed through, sorry. Back now because I actually need this at work, picking an enforcement threshold under a fixed recall floor, repeatedly, by hand.
@lorentzenchr your -1 was in favour of threshold selection for predict_proba (#4813, #8614, #16525). That shipped in 1.5, but the constrained objectives from that work (max_precision_at_recall_constraint + constraint_value) were dropped before release — so there's still no way to express a recall-constrained objective as a scorer.
I have an implementation ready with tests and docs, same max semantics as the closed #24671. Is the Dec 2022 scope question settled? If @jnothman's docs-instead-of-metric suggestion is preferred, I'll do that version.