Classification Metrics
Usage
classification_metrics(
true_labels,
predicted_labels,
predicted_prob = NULL,
binclasspos = 2L,
calc_auc = TRUE,
calc_brier = TRUE,
auc_method = "lightAUC",
sample = character(),
verbosity = 0L
)Arguments
- true_labels
Factor: True labels.
- predicted_labels
Factor: predicted values.
- predicted_prob
Numeric vector: predicted probabilities.
- binclasspos
Integer: Factor level position of the positive class in binary classification.
- calc_auc
Logical: If TRUE, calculate AUC. May be slow in very large datasets.
- calc_brier
Logical: If TRUE, calculate Brier_Score.
- auc_method
Character: "lightAUC", "pROC", "ROCR".
- sample
Character: Sample name.
- verbosity
Integer: Verbosity level.
Details
Note that auc_method = "pROC" is the only one that will output an AUC even if one or more predicted probabilities are NA.
Examples
# Assume positive class is "b"
true_labels <- factor(c("a", "a", "a", "b", "b", "b", "b", "b", "b", "b"))
predicted_labels <- factor(c("a", "b", "a", "b", "b", "a", "b", "b", "b", "a"))
predicted_prob <- c(0.3, 0.55, 0.45, 0.75, 0.57, 0.3, 0.8, 0.63, 0.62, 0.39)
classification_metrics(true_labels, predicted_labels, predicted_prob)
#> < Classification Metrics>
#> Predicted
#> Reference b a
#> b 5 2
#> a 1 2
#>
#> Overall
#> Sensitivity 0.714
#> Specificity 0.667
#> Balanced_Accuracy 0.690
#> PPV 0.833
#> NPV 0.500
#> F1 0.769
#> Accuracy 0.700
#> AUC 0.786
#> Brier_Score 0.203
#>
#> Positive Class b
classification_metrics(true_labels, predicted_labels, 1 - predicted_prob, binclasspos = 1L)
#> < Classification Metrics>
#> Predicted
#> Reference a b
#> a 2 1
#> b 2 5
#>
#> Overall
#> Sensitivity 0.667
#> Specificity 0.714
#> Balanced_Accuracy 0.690
#> PPV 0.500
#> NPV 0.833
#> F1 0.571
#> Accuracy 0.700
#> AUC 0.786
#> Brier_Score 0.203
#>
#> Positive Class a