-
Notifications
You must be signed in to change notification settings - Fork 31
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
case weights #96
Comments
I agree this would be cool. Do you have a reference on how this is implemented in the context of ROC curves? |
The curve would be based on the weighted versions of sensitivity and specificity. library(tidymodels)
#> Registered S3 method overwritten by 'tune':
#> method from
#> required_pkgs.model_spec parsnip
data(pathology)
str(pathology)
#> 'data.frame': 344 obs. of 2 variables:
#> $ pathology: Factor w/ 2 levels "abnorm","norm": 1 1 1 1 1 1 1 1 1 1 ...
#> $ scan : Factor w/ 2 levels "abnorm","norm": 1 1 1 1 1 1 1 1 1 1 ...
set.seed(1)
pathology$weights <- runif(nrow(pathology))
event <- "abnorm"
unweighted <-
sum(pathology$pathology == event & pathology$scan == event) /
sum(pathology$pathology == event)
unweighted
#> [1] 0.8953488
# via yardstick:
sensitivity(pathology, pathology, scan)
#> # A tibble: 1 × 3
#> .metric .estimator .estimate
#> <chr> <chr> <dbl>
#> 1 sens binary 0.895
weighted <-
sum( pathology$weights * (pathology$pathology == event & pathology$scan == event) ) /
sum( pathology$weights * (pathology$pathology == event) )
weighted
#> [1] 0.9013333 Created on 2021-09-13 by the reprex package (v2.0.0) @DavisVaughan has the start of changes that we will be making to |
I think I see. The easiest would be to directly update the roc.utils.perfs.all.fast to calculate TP/FP taking the weights into account:
A few thought on the implementation:
|
I'd love this feature too. WeightedROC package does it, but that package doesn't produce CIs. |
It would be great to have the calculations for the curve take into account cases weights (i.e. a non-negative, numeric vector of values the same length as the other data objects).
The text was updated successfully, but these errors were encountered: