Description Usage Arguments Details Value Examples
View source: R/plot_confusion_matrix.R
Plot a confusion matrix
1 2 3 4 5 6 | plot_confusion_matrix(
x,
target_col_name,
target_pred_col_name,
type = "heatmap"
)
|
x |
A data frame with two columns: the column with the actual classes; and the column with the predicted classes. Any other columns will be ignored. |
target_col_name |
A string with the column name of the target variable. |
target_pred_col_name |
A string with the column name of the predictions for the target variable. |
type |
A string indicating the of plot: "mosaic" or "heatmap". Defaults to- and currntly can only be- "heatmap". |
This function differs from ggplot2::autoplot
because the gradient
fills the heatmap (confusion matrix) based on absolute counts. It does
not make sense to compare colours between different "Truth" columns. By
contrast plot_confusion_matrix
expresses column counts as proportions
of the total count in that column. The proportions are used to define a
colour scale. The actual counts are plotted though.
A ggplot
(ggplot::geom_tile
).
1 2 3 4 5 6 7 | library(experienceAnalysis)
mtcars %>%
dplyr::mutate(carb_pred = sample(carb, size = nrow(.))) %>% # Mock predictions column
plot_confusion_matrix(
target_col_name = "carb",
target_pred_col_name = "carb_pred"
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.