categorical_summary | R Documentation |
Given the observed and predicted values of categorical data (of any number of classes) computes the confusion matrix, Kappa's coefficient, Matthews' correlation coefficient, accuracy, sensitivity, specificity, precision, F1 score and Brier's score.
categorical_summary(
observed,
predicted,
probabilities = NULL,
positive_class = NULL,
remove_na = TRUE
)
observed |
( |
predicted |
( |
probabilities |
( |
remove_na |
( |
A list with the confusion_matrix and all metrics. Matthews' correlation coefficient is only returned for binary data and Brier's score when the probabilities matrix is provided.
Other categorical_metrics:
accuracy()
,
brier_score()
,
confusion_matrix()
,
f1_score()
,
kappa_coeff()
,
math_mode()
,
matthews_coeff()
,
pccc()
,
pcic()
,
pr_auc()
,
precision()
,
recall()
,
roc_auc()
,
sensitivity()
,
specificity()
## Not run:
categorical_summary(c("a", "b"), c("a", "b"))
categorical_summary(c("a", "b"), c("b", "a"))
categorical_summary(c("a", "b", "a"), c("b", "a", "c"))
example <- data.frame(
observed = c("a", "a", "a", "a", "b", "b", "b", "b", "c", "c", "c", "c"),
predicted = c("a", "a", "b", "c", "a", "b", "b", "c", "a", "b", "b", "c"),
# Probabilities
a = c(
0.2377, 0.2924, 0.0406, 0.1893, 0.3978, 0.1965,
0.0673, 0.2796, 0.1921, 0.2020, 0.1752, 0.3428
),
b = c(
0.0432, 0.1948, 0.0835, 0.3969, 0.0749, 0.0250,
0.1507, 0.0752, 0.3952, 0.0807, 0.3097, 0.1282
),
c = c(
0.7190, 0.5126, 0.8757, 0.4136, 0.5272, 0.7783,
0.7818, 0.6451, 0.4125, 0.7172, 0.5150, 0.5288
)
)
categorical_summary(
example$observed,
example$predicted,
probabilities = example[, c("a", "b", "c")]
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.