fix(pr-curve): set precision to NaN when TP+FP == 0#3227
Merged
Borda merged 6 commits intoAug 15, 2025
Conversation
iamkulbhushansingh
requested review from
Borda,
SkafteNicki and
justusschock
as code owners
August 13, 2025 20:09
iamkulbhushansingh
added a commit
to iamkulbhushansingh/torchmetrics
that referenced
this pull request
Aug 13, 2025
iamkulbhushansingh
force-pushed
the
fix/pr-curve-nan-precision
branch
from
August 13, 2025 20:29
dcb4197 to
011096f
Compare
iamkulbhushansingh
marked this pull request as draft
August 13, 2025 20:33
iamkulbhushansingh
marked this pull request as ready for review
August 15, 2025 10:53
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3227 +/- ##
========================================
- Coverage 69% 40% -28%
========================================
Files 364 349 -15
Lines 20073 19882 -191
========================================
- Hits 13788 7993 -5795
- Misses 6285 11889 +5604 🚀 New features to boost your workflow:
|
Borda
approved these changes
Aug 15, 2025
Borda
added a commit
that referenced
this pull request
Sep 3, 2025
* fix(pr-curve): set precision to NaN when TP+FP == 0 * fixed average precision affected due to precision recall curve * fix doctest for precision recall curve * updated chlog --------- Co-authored-by: Jirka Borovec <[email protected]> (cherry picked from commit e286bf7)
Borda
added a commit
that referenced
this pull request
Sep 3, 2025
* fix(pr-curve): set precision to NaN when TP+FP == 0 * fixed average precision affected due to precision recall curve * fix doctest for precision recall curve * updated chlog --------- Co-authored-by: Jirka Borovec <[email protected]> (cherry picked from commit e286bf7)
15 tasks
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.
What does this PR do?
Completely Fixes #2873
Before submitting
Summary
This change updates
BinaryPrecisionRecallCurveso that when no predictions meet a given threshold (TP + FP = 0), precision is returned asNaN(undefined) while recall remains at0.0.This reflects the mathematically correct definitions for these metrics and avoids misleading
(0, 0)points caused by forced zero precision.Motivation
Previously, when no predictions met the threshold, both precision and recall were set to
0.0.TP + FP) is zero, and returning0.0is misleading.0.0since the denominator (TP + FN) is non-zero.By returning
NaNfor precision, users can filter out these undefined points in PR curve analysis while retaining meaningful recall values.Did you have fun?
💯
📚 Documentation preview 📚: https://torchmetrics--3227.org.readthedocs.build/en/3227/