Computes Area Under the ROC Curve (AUC) for model predictions using the ROCR package. Handles binary classification models from glmnet.
Examples
if (requireNamespace("glmnet", quietly = TRUE) &&
requireNamespace("ROCR", quietly = TRUE)) {
set.seed(123)
train_data <- matrix(rnorm(100 * 5), ncol = 5)
train_outcome <- rbinom(100, 1, 0.5)
test_data <- matrix(rnorm(50 * 5), ncol = 5)
test_outcome <- rbinom(50, 1, 0.5)
fitted_model <- glmnet::cv.glmnet(train_data, train_outcome, family = "binomial", nfolds = 5)
auc_value <- BinomialAUC(fitted_model, test_data, fitted_model$lambda.min, test_outcome)
print(auc_value)
}
#> [1] 0.4879227