% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/geoms-ml.R
\name{geom_confusion_matrix}
\alias{geom_confusion_matrix}
\title{Confusion matrix}
\usage{
geom_confusion_matrix(
  mapping = NULL,
  data = NULL,
  normalize = "row",
  label_size = NULL
)
}
\arguments{
\item{mapping, data}{Standard layer overrides. Map the predicted class to
\code{x}, the actual class to \code{y}. Provide counts via \code{size}, or pass raw
per-observation rows and let the stat count them.}

\item{normalize}{\code{"row"} (default), \code{"col"}, \code{"all"}, or \code{"none"} —
which total the shading is relative to.}

\item{label_size}{Annotation size in px.}
}
\value{
A \link{Layer} to add with \code{+}.
}
\description{
A tile heatmap of predicted vs actual classes, shaded by row-normalized
rate and annotated with counts, so class imbalance does not hide errors.
}
\examples{
d <- data.frame(
  predicted = c("cat", "cat", "dog", "dog", "dog", "cat"),
  actual    = c("cat", "dog", "dog", "dog", "cat", "cat")
)
ggnext(d, aes(predicted, actual)) + geom_confusion_matrix()
}
