plot_confusion_matrix

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

plot_confusion_matrix(y_true: ndarray, y_pred: ndarray, *, title: str = 'Confusion Matrix', class_names: Sequence[str] | None = None, normalize: bool = False, colorbar: bool | Mapping[str, Any] = True)[source]

Confusion-matrix heatmap for discrete class predictions.

Parameters:
  • y_true – Ground-truth class labels.

  • y_pred – Predicted class labels (same length as y_true).

  • title – Figure title (sanitised).

  • class_names – Optional tick labels only (same length as the sorted unique values in y_true / y_pred). Never used as sklearn labels= — those must be the actual array values.

  • normalize – When True, row-normalise to proportions.

  • colorbar – Draw a short vertical colorbar (default True). Pass False to hide it, or a mapping of style kwargs (shrink, pad, fraction, aspect, ticks, label, …) to override the default.

Returns:

The matplotlib Figure.