[MRG] Bugfix for precision_recall_curve when all labels are negative#14621
Closed
varunagrawal wants to merge 1 commit intoscikit-learn:masterfrom
Closed
[MRG] Bugfix for precision_recall_curve when all labels are negative#14621varunagrawal wants to merge 1 commit intoscikit-learn:masterfrom
varunagrawal wants to merge 1 commit intoscikit-learn:masterfrom
Conversation
de354dd to
fa9c35a
Compare
Contributor
|
Hi @varunagrawal, are you still interested in finishing this PR? If yes, do you mind resolving conflicts? Thanks for your work! |
Contributor
Author
|
There are a couple of things that need to be addressed as per #8280. Thanks for the patience. |
fa9c35a to
3d4070c
Compare
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 Issue
Fixes #8245
What does this implement/fix? Explain your changes.
When all the
y_truelabels are negative,precision_recall_curvereturnsnanbecause ofrecallbeing set tonaninstead of1. This is because of the direction division of thetpsvector bytps[-1]which happens to be0.This fix checks if
tps[-1]is0and if yes, sets the recall to1directly since there are no True Positives or False Negatives, else we calculaterecallas normal.Any other comments?
I had to update
test_precision_recall_curve_toydatasince this test was expecting theTrueDivideexception to be raised which is no longer the case as a result of this fix. I added 2 test cases, one to check when all truth labels are negative and the other to check when all truth labels are positive to ensure precision calculation is accurate.