powered by
Evaluates the performance of a binary classification model using a confusion matrix and accuracy.
measure_bin(obs, pred, cut = 0.5)
A list containing:
conf_mat
A confusion matrix comparing observed and predicted class labels.
accuracy
The proportion of correct predictions.
ROC
ROC generated using pROC::roc
pROC::roc
AUC
Area under the ROC curve.
A numeric or integer vector of observed binary class labels (0 or 1).
A numeric vector of predicted probabilities for the positive class.
A numeric threshold (between 0 and 1) to classify predictions into binary labels.
obs <- c(1, 0, 1, 1, 0) pred <- c(0.9, 0.4, 0.8, 0.7, 0.3) cut <- 0.5 measure_bin(obs, pred, cut) # Returns: list(conf_mat = , accuracy = 1, ROC = , AUC = 1)
Run the code above in your browser using DataLab