Last active
May 21, 2017 03:45
-
-
Save Torenable/7a788e68a5d17c82217d905ce7c22b70 to your computer and use it in GitHub Desktop.
Use pROC to evaluate classification in R
This file contains 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
# library(pROC) | |
#---------------------------------- | |
# Compute the ROC | |
#---------------------------------- | |
pROC::roc($pred_p, $actual) | |
pROC::roc( | |
actual ~ pred, | |
data.frame( | |
pred = $pred_p, | |
actual = $actual | |
) | |
) | |
#---------------------------------- | |
# Find out the threshold | |
#---------------------------------- | |
pROC::ci(roc_obj, of="thresholds", thresholds="best") | |
# ci.auc | |
# ci.se | |
# ci.sp | |
# ci.thresholds | |
#---------------------------------- | |
# Plot the result | |
#---------------------------------- | |
pROC::ci.se(roc_obj, specificities = seq(0, 100, 5), parallel = T) %>% plot(type = "shape") # plot confidential intervals | |
pROC::ci(roc_obj, of = "thresholds", thresholds = "best") %>% plot() # plot the spot of threshold |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment