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
Name | Type | Description |
---|---|---|
opts? | object | - |
opts.confusion_matrix? | ArrayLike [] | Confusion matrix. |
opts.display_labels? | ArrayLike | Display labels for plot. If undefined , display labels are set from 0 to n\_classes \- 1 . |
Returns
Defined in: generated/metrics/ConfusionMatrixDisplay.ts:25 (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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.X? | ArrayLike | Input values. |
opts.ax? | any | Axes object to plot on. If undefined , a new figure and axes is created. |
opts.cmap? | string | Colormap recognized by matplotlib. Default Value 'viridis' |
opts.colorbar? | boolean | Whether or not to add a colorbar to the plot. Default Value true |
opts.display_labels? | ArrayLike | Target 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? | any | Fitted classifier or a fitted Pipeline in which the last estimator is a classifier. |
opts.im_kw? | any | Dict with keywords passed to matplotlib.pyplot.imshow call. |
opts.include_values? | boolean | Includes values in confusion matrix. Default Value true |
opts.labels? | ArrayLike | List 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? | ArrayLike | Sample weights. |
opts.text_kw? | any | Dict with keywords passed to matplotlib.pyplot.text call. |
opts.values_format? | string | Format 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? | ArrayLike | Target 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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.ax? | any | Axes object to plot on. If undefined , a new figure and axes is created. |
opts.cmap? | string | Colormap recognized by matplotlib. Default Value 'viridis' |
opts.colorbar? | boolean | Whether or not to add a colorbar to the plot. Default Value true |
opts.display_labels? | ArrayLike | Target 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? | any | Dict with keywords passed to matplotlib.pyplot.imshow call. |
opts.include_values? | boolean | Includes values in confusion matrix. Default Value true |
opts.labels? | ArrayLike | List 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? | ArrayLike | Sample weights. |
opts.text_kw? | any | Dict with keywords passed to matplotlib.pyplot.text call. |
opts.values_format? | string | Format 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? | ArrayLike | The predicted labels given by the method predict of an classifier. |
opts.y_true? | ArrayLike | True 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
Name | Type |
---|---|
py | PythonBridge |
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
Name | Type | Description |
---|---|---|
opts | object | - |
opts.ax? | any | Axes object to plot on. If undefined , a new figure and axes is created. |
opts.cmap? | string | Colormap recognized by matplotlib. Default Value 'viridis' |
opts.colorbar? | boolean | Whether or not to add a colorbar to the plot. Default Value true |
opts.im_kw? | any | Dict with keywords passed to matplotlib.pyplot.imshow call. |
opts.include_values? | boolean | Includes values in confusion matrix. Default Value true |
opts.text_kw? | any | Dict with keywords passed to matplotlib.pyplot.text call. |
opts.values_format? | string | Format 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)
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
Name | Type |
---|---|
pythonBridge | PythonBridge |
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)