confusion_matrix {mlr3measures} | R Documentation |
Calculate Binary Confusion Matrix
Description
Calculates the confusion matrix for a binary classification problem once and then calculates all confusion measures of this package.
Usage
confusion_matrix(truth, response, positive, na_value = NaN, relative = FALSE)
Arguments
truth |
( |
response |
( |
positive |
( |
na_value |
( |
relative |
( |
Value
List with two elements:
-
matrix
stores the calculated confusion matrix. -
measures
stores the metrics as named numeric vector.
Examples
set.seed(123)
lvls = c("a", "b")
truth = factor(sample(lvls, 20, replace = TRUE), levels = lvls)
response = factor(sample(lvls, 20, replace = TRUE), levels = lvls)
confusion_matrix(truth, response, positive = "a")
confusion_matrix(truth, response, positive = "a", relative = TRUE)
confusion_matrix(truth, response, positive = "b")