-
Notifications
You must be signed in to change notification settings - Fork 60
Correct the pr_curve() implementation when duplicates exist
#95
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
Conversation
- Initialize with first case - Reverse increment / append order
…ned (`tp / tp+fp` when tp=0, fp=0). This ensures the graph always starts in the correct location.
pr_curve() implementation when duplicates exist
Codecov Report
@@ Coverage Diff @@
## master #95 +/- ##
==========================================
- Coverage 96.25% 96.14% -0.11%
==========================================
Files 44 44
Lines 2294 2311 +17
==========================================
+ Hits 2208 2222 +14
- Misses 86 89 +3
Continue to review full report at Codecov.
|
|
This known (pathological) example demonstrates fixing a bug with
After: suppressPackageStartupMessages(library(yardstick))
truth <- factor(c("a", "b", "a", "a"))
estimate <- c(.9, .9, .4, .3)
df <- data.frame(truth, estimate)
pr_curve(df, truth, estimate)
#> # A tibble: 4 x 3
#> .threshold recall precision
#> <dbl> <dbl> <dbl>
#> 1 Inf 0 1
#> 2 0.9 0.333 0.5
#> 3 0.4 0.667 0.667
#> 4 0.3 1 0.75Before: suppressPackageStartupMessages(library(yardstick))
truth <- factor(c("a", "b", "a", "a"))
estimate <- c(.9, .9, .4, .3)
df <- data.frame(truth, estimate)
pr_curve(df, truth, estimate)
#> # A tibble: 4 x 3
#> .threshold recall precision
#> <dbl> <dbl> <dbl>
#> 1 Inf 0 NA
#> 2 0.9 0.25 1
#> 3 0.4 0.75 1
#> 4 0.3 1 1 |
|
This PR now also implements |
|
@dariyasydykova at this point, this PR fixes all of the issues with It doesn't look like your tweet got any solid advice either: |
|
Hi, I am using yardstick for evaluating ML models and it seems I got hit by this issue in pr_curve calculation. Any plan when this would get merged and released? |
|
I'll likely make a pass at all the outstanding yardstick issues / PRs after useR (July 9-12), and then release a new version. Things are pretty packed up until then. |
|
Thanks. Will use this branch until then. |
|
This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue. |
Closes #93. Below are 3 examples that were incorrect before, but are now working correctly. The main issue had to do with how duplicate probability values were handled.
This also affected how the PR AUC values were computed for each example. They are now computed correctly for each example. For this, its important to have the
1value rather than anNAfor the first precision value. Without it, the AUC value for all of these won't actually be 1, as it should be, because the curve won't cover the full precision/recall range.No duplicates (this was correct before and after the change)
After:
Before:
Duplicates at the beginning
After:
Before:
Duplicates at the end
After:
Before: