measure_bin | R Documentation |
Evaluates the performance of a binary classification model using a confusion matrix and accuracy.
measure_bin(obs, pred, cut = 0.5)
obs |
A numeric or integer vector of observed binary class labels (0 or 1). |
pred |
A numeric vector of predicted probabilities for the positive class. |
cut |
A numeric threshold (between 0 and 1) to classify predictions into binary labels. |
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
AUC
Area under the ROC curve.
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 = <confusion matrix>, accuracy = 1, ROC = <ROC>, AUC = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.