function wandb.plot.confusion_matrix()
Constructs a confusion matrix from a sequence of probabilities or predictions.Args
Sequence[Sequence[float]] | None
A sequence of predicted probabilities for each class. The sequence shape should be (N, K) where N is the number of samples and K is the number of classes. If provided,
preds should not be provided.Sequence[T] | None
A sequence of true labels.
Sequence[T] | None
A sequence of predicted class labels. If provided,
probs should not be provided.Sequence[str] | None
Sequence of class names. If not provided, class names will be defined as “Class_1”, “Class_2”, etc.
str
Title of the confusion matrix chart.
bool
Whether the table should be split into a separate section in the W&B UI. If
True, the table will be displayed in a section named “Custom Chart Tables”. Default is False.Returns
CustomChart: A custom chart object that can be logged to W&B. To log the chart, pass it to wandb.log().
Raises
ValueError: If bothprobsandpredsare provided or if the number of predictions and true labels are not equal. If the number of unique predicted classes exceeds the number of class names or if the number of unique true labels exceeds the number of class names.wandb.Error: If numpy is not installed.