Skip to content

Instantly share code, notes, and snippets.

@Torenable
Last active May 21, 2017 03:45
Show Gist options
  • Save Torenable/7a788e68a5d17c82217d905ce7c22b70 to your computer and use it in GitHub Desktop.
Save Torenable/7a788e68a5d17c82217d905ce7c22b70 to your computer and use it in GitHub Desktop.
Use pROC to evaluate classification in R
# 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