plot_confusion_matrix.Rd
Plot a confusion matrix
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". |
A ggplot
(ggplot::geom_tile
).
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.