Documentation
Classes
ConfusionMatrixDisplay

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 (opens in a new tab)

Constructors

constructor()

Signature

new ConfusionMatrixDisplay(opts?: object): ConfusionMatrixDisplay;

Parameters

NameTypeDescription
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 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:21 (opens in a new tab)

id

string

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:18 (opens in a new tab)

opts

any

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:19 (opens in a new tab)

Accessors

ax_

Axes with confusion matrix.

Signature

ax_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:532 (opens in a new tab)

figure_

Figure containing the confusion matrix.

Signature

figure_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:559 (opens in a new tab)

im_

Image representing the confusion matrix.

Signature

im_(): Promise<any>;

Returns

Promise<any>

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:478 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:40 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:44 (opens in a new tab)

text_

Array of matplotlib axes. undefined if include\_values is false.

Signature

text_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:505 (opens in a new tab)

Methods

dispose()

Disposes of the underlying Python resources.

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

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:102 (opens in a new tab)

from_estimator()

Plot Confusion Matrix given an estimator and some data.

Read more in the User Guide.

Signature

from_estimator(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLikeInput values.
opts.ax?anyAxes object to plot on. If undefined, a new figure and axes is created.
opts.cmap?stringColormap recognized by matplotlib. Default Value 'viridis'
opts.colorbar?booleanWhether or not to add a colorbar to the plot. Default Value true
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. Default Value true
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. Default Value 'horizontal'
opts.y?ArrayLikeTarget values.

Returns

Promise<any>

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:121 (opens in a new tab)

from_predictions()

Plot Confusion Matrix given true and predicted labels.

Read more in the User Guide.

Signature

from_predictions(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.ax?anyAxes object to plot on. If undefined, a new figure and axes is created.
opts.cmap?stringColormap recognized by matplotlib. Default Value 'viridis'
opts.colorbar?booleanWhether or not to add a colorbar to the plot. Default Value true
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. Default Value true
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. Default Value 'horizontal'
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:261 (opens in a new tab)

init()

Initializes the underlying Python resources.

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

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:53 (opens in a new tab)

plot()

Plot visualization.

Signature

plot(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.ax?anyAxes object to plot on. If undefined, a new figure and axes is created.
opts.cmap?stringColormap recognized by matplotlib. Default Value 'viridis'
opts.colorbar?booleanWhether or not to add a colorbar to the plot. Default Value true
opts.im_kw?anyDict with keywords passed to matplotlib.pyplot.imshow call.
opts.include_values?booleanIncludes values in confusion matrix. Default Value true
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. Default Value 'horizontal'

Returns

Promise<any>

Defined in: generated/metrics/ConfusionMatrixDisplay.ts:394 (opens in a new tab)