View source: R/confusion_matrix.R
confusion_matrix | R Documentation |
Calculates the confusion matrix for a binary classification problem once and then calculates all binary confusion measures of this package.
confusion_matrix(truth, response, positive, na_value = NaN, relative = FALSE)
truth |
( |
response |
( |
positive |
( |
na_value |
( |
relative |
( |
The binary confusion matrix is defined as
\begin{pmatrix}
TP & FP \\
FN & TN
\end{pmatrix}.
If relative = TRUE
, all values are divided by n
.
List with two elements:
matrix
stores the calculated confusion matrix.
measures
stores the metrics as named numeric vector.
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.