A receiver operating characteristic (ROC) curve evaluates a binary classifier across decision thresholds. It plots sensitivity—the true positive rate—against specificity, shown here on the x-axis, to reveal how well the model distinguishes positive from negative cases. section 14.6.2
Use ROC analysis to separate threshold-dependent prediction results from overall discriminatory power:
- Sensitivity measures correctly identified positive cases, while specificity measures correctly identified negative cases. section 14.6.2
- The area under the curve (AUC) summarizes discriminatory power: 1 represents perfect separation, 0.5 represents random performance, and higher values are better. section 14.6.2
- Unlike error rate and accuracy, which summarize individual thresholded predictions, AUC evaluates how well the model distinguishes positive from negative instances overall. section 14.6.2
Predicting NBA playoff qualification
A logistic regression predicts whether an NBA team reaches the playoffs. After comparing actual outcomes with predicted values, pROC computes an AUC of 0.73, indicating fairly strong predictive power. Base R then plots the curve with sensitivity on the y-axis and specificity on the x-axis: roc_curve <- roc(actuals$actual_values, predictions$predicted_values2) plot(roc_curve, col = "red", main = "ROC Curve: AUC = 0.73", xlab = "Specificity", ylab = "Sensitivity") section 14.6.2
packages <- c("tidyverse", "patchwork", "ggpubr", "pscl", "SciViews",
"questionr", "caret", "pROC")
lapply(packages, library, character.only = TRUE)
Load pROC alongside the modeling and visualization packages used to compute and display ROC curves. section 14.1






