class sklearn.metrics.ConfusionMatrixDisplay(confusion_matrix, *, display_labels=None)[source]

Confusion Matrix visualization.

It is recommend to use plot_confusion_matrix to create a ConfusionMatrixDisplay. All parameters are stored as attributes.

Read more in the User Guide.

confusion_matrixndarray of shape (n_classes, n_classes)

Confusion matrix.

display_labelsndarray of shape (n_classes,), default=None

Display labels for plot. If None, display labels are set from 0 to n_classes - 1.

im_matplotlib AxesImage

Image representing the confusion matrix.

text_ndarray of shape (n_classes, n_classes), dtype=matplotlib Text, or None

Array of matplotlib axes. None if include_values is false.

ax_matplotlib Axes

Axes with confusion matrix.

figure_matplotlib Figure

Figure containing the confusion matrix.


plot(self, \*[, include_values, cmap, …])

Plot visualization.

__init__(self, confusion_matrix, *, display_labels=None)[source]

Initialize self. See help(type(self)) for accurate signature.

plot(self, *, include_values=True, cmap='viridis', xticks_rotation='horizontal', values_format=None, ax=None)[source]

Plot visualization.

include_valuesbool, default=True

Includes values in confusion matrix.

cmapstr or matplotlib Colormap, default=’viridis’

Colormap recognized by matplotlib.

xticks_rotation{‘vertical’, ‘horizontal’} or float, default=’horizontal’

Rotation of xtick labels.

values_formatstr, default=None

Format specification for values in confusion matrix. If None, the format specification is ‘d’ or ‘.2g’ whichever is shorter.

axmatplotlib axes, default=None

Axes object to plot on. If None, a new figure and axes is created.


Examples using sklearn.metrics.ConfusionMatrixDisplay