jj_plot_confusion_matrix: confusion_matrix

View source: R/jj_confusion_matrix.R

jj_plot_confusion_matrixR Documentation

confusion_matrix

Description

plot a confusion matrix based on two vectors of equal length

Usage

jj_plot_confusion_matrix(
  vector_a,
  vector_b,
  xlab_text = "vector_a",
  ylab_text = "vector_b",
  plot_absolute = F,
  plot_numbers = F,
  text_size = 2
)

Arguments

vector_a

first vector, e.g. true label

vector_b

second vector, e.g. predicted label

xlab_text

x label

ylab_text

y label

plot_absolute

if FALSE, show the relative fraction of values for each cell

plot_numbers

show count in fields

text_size

size of text

Value

Returns a confusion matrix as heatmap

Examples

true_label = c('A','A','A','B','B','B')
predicted_label = c('A','B','B','B','B','B')
#percentage of the total observations that are in the respective field
jj_plot_confusion_matrix(vector_a = true_label, vector_b = predicted_label,
                        xlab_text = 'true value', ylab_text = 'predicted value', 
                        plot_numbers = T, text_size = 10)
# absolute
jj_plot_confusion_matrix(vector_a = true_label, vector_b = predicted_label,
                        xlab_text = 'true value', ylab_text = 'predicted value', 
                        plot_numbers = T, text_size = 10, plot_absolute = T)

mathosi/jj documentation built on Feb. 25, 2024, 2:29 p.m.