Plot a binary confusion matrix as a heatmap with TP, FP, FN, TN labels.
Source:R/plot_confusion_matrix.R
plot_confusion_matrix.Rd
Computes a confusion matrix for binary classification tasks. Takes binary vectors of true and predicted labels. Uses the `target` value to define the positive class. Cells are labeled with TP, FP, FN, TN and counts. Class labels shown as "1" (positive) and "0" (negative). Uses ggplot2 with a simple blue color scale.
Usage
plot_confusion_matrix(
y_true,
y_selected,
target = 1,
title = NULL,
x_label = NULL,
y_label = NULL,
caption = NULL
)
Arguments
- y_true
Vector of true labels (numeric, factor, or logical).
- y_selected
Vector of predicted labels (numeric, factor, or logical).
- target
The value that should be treated as the positive class.
- title
Optional plot title.
- x_label
Optional x-axis label (default: "True Label").
- y_label
Optional y-axis label (default: "Predicted Label").