-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corrected f_beta computation #4183
Conversation
Added METRIC_EPS in the denominator to avoid nan values in f_beta score.
Hello @abhinavg97! Thanks for updating this PR.
Comment last updated at 2020-10-21 08:07:39 UTC |
Made changes flake8 compliant
Codecov Report
@@ Coverage Diff @@
## master #4183 +/- ##
=======================================
- Coverage 90% 89% -1%
=======================================
Files 103 103
Lines 7863 8313 +450
=======================================
+ Hits 7064 7403 +339
- Misses 799 910 +111 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this offset epsilon adding to all is not good, we shall check it there are zeros and then add it just there, well if know that some are rore just retunt the output...
@justusschock @SkafteNicki
We have this function (still used in functional) that took care of this: |
Makes use of class_reduce for macro f_beta computation to avoid nans
Made flake8 compliant
@abhinavg97 is it correct that this happens when both |
Yes, that's right. Here is an example:
Yeah I think we can add a test for this. Is it okay if I add the above case as a test? |
can we add a test to verify that these changes fix the actual master...? |
@abhinavg97 can you add the following testcase to
|
Yes sure, will do. Thanks for the pointer to the input location :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR ! Thanks !
@@ -124,9 +125,11 @@ def compute(self): | |||
precision = self.true_positives.sum().float() / (self.predicted_positives.sum() + METRIC_EPS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really want to keep our metric systematically unprecise by adding some offset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can move towards class_reduce
function which explicit handles nans
, when we unify the class based metrics and functional metrics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, makes sense. Just checked and the tests pass without METRIC_EPS. Pushing the update now.
Added METRIC_EPS in the denominator of computation to avoid nan values in f_beta score.
What does this PR do?
Will give the correct f_beta score and prevent outputting nan values for multilabel classification with macro.
Fixes #4187
Before submitting
PR review
Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.
Did you have fun?
Make sure you had fun coding 🙃 👍