DocumentationClassesConfusionMatrixDisplay

Class: ConfusionMatrixDisplay

Confusion Matrix visualization.

It is recommend to use from_estimator or from_predictions to create a ConfusionMatrixDisplay. All parameters are stored as attributes.

Read more in the User Guide.

Python Reference

Constructors

new ConfusionMatrixDisplay()

new ConfusionMatrixDisplay(opts?): ConfusionMatrixDisplay

Parameters

ParameterTypeDescription
opts?object-
opts.confusion_matrix?ArrayLike[]Confusion matrix.
opts.display_labels?ArrayLikeDisplay labels for plot. If undefined, display labels are set from 0 to n_classes \- 1.

Returns ConfusionMatrixDisplay

Defined in generated/metrics/ConfusionMatrixDisplay.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/metrics/ConfusionMatrixDisplay.ts:23
_isInitializedbooleanfalsegenerated/metrics/ConfusionMatrixDisplay.ts:22
_pyPythonBridgeundefinedgenerated/metrics/ConfusionMatrixDisplay.ts:21
idstringundefinedgenerated/metrics/ConfusionMatrixDisplay.ts:18
optsanyundefinedgenerated/metrics/ConfusionMatrixDisplay.ts:19

Accessors

ax_

Get Signature

get ax_(): Promise<any>

Axes with confusion matrix.

Returns Promise<any>

Defined in generated/metrics/ConfusionMatrixDisplay.ts:471


figure_

Get Signature

get figure_(): Promise<any>

Figure containing the confusion matrix.

Returns Promise<any>

Defined in generated/metrics/ConfusionMatrixDisplay.ts:498


im_

Get Signature

get im_(): Promise<any>

Image representing the confusion matrix.

Returns Promise<any>

Defined in generated/metrics/ConfusionMatrixDisplay.ts:417


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/metrics/ConfusionMatrixDisplay.ts:40


text_

Get Signature

get text_(): Promise<ArrayLike[]>

Array of matplotlib axes. undefined if include_values is false.

Returns Promise<ArrayLike[]>

Defined in generated/metrics/ConfusionMatrixDisplay.ts:444

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Returns Promise<void>

Defined in generated/metrics/ConfusionMatrixDisplay.ts:96


from_estimator()

from_estimator(opts): Promise<any>

Plot Confusion Matrix given an estimator and some data.

Read more in the User Guide.

Parameters

ParameterTypeDescription
optsobject-
opts.ax?anyAxes object to plot on. If undefined, a new figure and axes is created.
opts.cmap?stringColormap recognized by matplotlib.
opts.colorbar?booleanWhether or not to add a colorbar to the plot.
opts.display_labels?ArrayLikeTarget names used for plotting. By default, labels will be used if it is defined, otherwise the unique labels of y_true and y_pred will be used.
opts.estimator?anyFitted classifier or a fitted Pipeline in which the last estimator is a classifier.
opts.im_kw?anyDict with keywords passed to matplotlib.pyplot.imshow call.
opts.include_values?booleanIncludes values in confusion matrix.
opts.labels?ArrayLikeList of labels to index the confusion matrix. This may be used to reorder or select a subset of labels. If undefined is given, those that appear at least once in y_true or y_pred are used in sorted order.
opts.normalize?"all" | "true" | "pred"Either to normalize the counts display in the matrix:
opts.sample_weight?ArrayLikeSample weights.
opts.text_kw?anyDict with keywords passed to matplotlib.pyplot.text call.
opts.values_format?stringFormat specification for values in confusion matrix. If undefined, the format specification is ‘d’ or ‘.2g’ whichever is shorter.
opts.X?ArrayLikeInput values.
opts.xticks_rotation?number | "vertical" | "horizontal"Rotation of xtick labels.
opts.y?ArrayLikeTarget values.

Returns Promise<any>

Defined in generated/metrics/ConfusionMatrixDisplay.ts:115


from_predictions()

from_predictions(opts): Promise<any>

Plot Confusion Matrix given true and predicted labels.

Read more in the User Guide.

Parameters

ParameterTypeDescription
optsobject-
opts.ax?anyAxes object to plot on. If undefined, a new figure and axes is created.
opts.cmap?stringColormap recognized by matplotlib.
opts.colorbar?booleanWhether or not to add a colorbar to the plot.
opts.display_labels?ArrayLikeTarget names used for plotting. By default, labels will be used if it is defined, otherwise the unique labels of y_true and y_pred will be used.
opts.im_kw?anyDict with keywords passed to matplotlib.pyplot.imshow call.
opts.include_values?booleanIncludes values in confusion matrix.
opts.labels?ArrayLikeList of labels to index the confusion matrix. This may be used to reorder or select a subset of labels. If undefined is given, those that appear at least once in y_true or y_pred are used in sorted order.
opts.normalize?"all" | "true" | "pred"Either to normalize the counts display in the matrix:
opts.sample_weight?ArrayLikeSample weights.
opts.text_kw?anyDict with keywords passed to matplotlib.pyplot.text call.
opts.values_format?stringFormat specification for values in confusion matrix. If undefined, the format specification is ‘d’ or ‘.2g’ whichever is shorter.
opts.xticks_rotation?number | "vertical" | "horizontal"Rotation of xtick labels.
opts.y_pred?ArrayLikeThe predicted labels given by the method predict of an classifier.
opts.y_true?ArrayLikeTrue labels.

Returns Promise<any>

Defined in generated/metrics/ConfusionMatrixDisplay.ts:231


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/metrics/ConfusionMatrixDisplay.ts:53


plot()

plot(opts): Promise<any>

Plot visualization.

Parameters

ParameterTypeDescription
optsobject-
opts.ax?anyAxes object to plot on. If undefined, a new figure and axes is created.
opts.cmap?stringColormap recognized by matplotlib.
opts.colorbar?booleanWhether or not to add a colorbar to the plot.
opts.im_kw?anyDict with keywords passed to matplotlib.pyplot.imshow call.
opts.include_values?booleanIncludes values in confusion matrix.
opts.text_kw?anyDict with keywords passed to matplotlib.pyplot.text call.
opts.values_format?stringFormat specification for values in confusion matrix. If undefined, the format specification is ‘d’ or ‘.2g’ whichever is shorter.
opts.xticks_rotation?number | "vertical" | "horizontal"Rotation of xtick labels.

Returns Promise<any>

Defined in generated/metrics/ConfusionMatrixDisplay.ts:340