Plot confusion matrix, either with absolute numbers or percentages per column (true labels).
Usage
plot_cm(
cm,
perc = FALSE,
cm_labels,
round_dig = 2,
text_size = 1,
highlight_diag = TRUE
)
Arguments
- cm
A confusion matrix
- perc
Whether to use absolute numbers or percentages.
- cm_labels
Labels corresponding to confusion matrix entries.
- round_dig
How to round numbers.
- text_size
Size of text annotations.
- highlight_diag
Whether to highlight entries in diagonal.
Value
A ggplot of a confusion matrix.
Examples
if (FALSE) { # reticulate::py_module_available("tensorflow")
cm <- matrix(c(90, 1, 0, 2, 7, 1, 8, 3, 1), nrow = 3, byrow = TRUE)
plot_cm(cm, perc = TRUE, cm_labels = paste0('label_', 1:3), text_size = 8)
}