confusion_matrix: Confusion matrix

View source: R/metrics.R

confusion_matrixR Documentation

Confusion matrix

Description

Given the observed and predicted values of categorical data (of any number of classes) computes the confusion matrix.

Usage

confusion_matrix(observed, predicted, remove_na = TRUE)

Arguments

observed

(factor) The observed values. It has to have the same length as predicted.

predicted

(factor) The observed values. It has to have the same length as observed.

remove_na

(logical(1)) Should NA values be removed?. TRUE by default.

Value

An object of class table with the confusion matrix.

See Also

Other categorical_metrics: accuracy(), brier_score(), categorical_summary(), f1_score(), kappa_coeff(), math_mode(), matthews_coeff(), pccc(), pcic(), pr_auc(), precision(), recall(), roc_auc(), sensitivity(), specificity()

Examples

## Not run: 
confusion_matrix(factor("a"), factor("a"))
confusion_matrix(factor("a"), factor("b"))
confusion_matrix(factor(c("a", "b")), factor(c("c", "d")))
confusion_matrix(factor(c("a", "a")), factor(c("a", "a")))
confusion_matrix(iris$Species, iris$Species)

## End(Not run)


brandon-mosqueda/SKM documentation built on Feb. 8, 2025, 5:24 p.m.