Main Content

Create confusion matrix chart for classification problem

`confusionchart(`

creates a confusion matrix chart from true labels `trueLabels`

,`predictedLabels`

)`trueLabels`

and
predicted labels `predictedLabels`

and returns a
`ConfusionMatrixChart`

object. The rows of the confusion matrix
correspond to the true class and the columns correspond to the predicted class. Diagonal
and off-diagonal cells correspond to correctly and incorrectly classified observations,
respectively. Use `cm`

to modify the confusion matrix chart after it is
created. For a list of properties, see ConfusionMatrixChart Properties.

`confusionchart(`

creates a confusion matrix
chart from the numeric confusion matrix `m`

)`m`

. Use this syntax if you
already have a numeric confusion matrix in the workspace.

`confusionchart(`

specifies class labels that appear along the `m`

,`classLabels`

)*x*-axis and
*y*-axis. Use this syntax if you already have a numeric
confusion matrix and class labels in the workspace.

`confusionchart(`

creates the confusion chart in the figure, panel, or tab specified by
`parent`

,___)`parent`

.

`confusionchart(___,`

specifies additional `Name,Value`

)`ConfusionMatrixChart`

properties using one or
more name-value pair arguments. Specify the properties after all other input arguments.
For a list of properties, see ConfusionMatrixChart Properties.

returns
the `cm`

= confusionchart(___)`ConfusionMatrixChart`

object. Use `cm`

to modify
properties of the chart after creating it. For a list of properties, see ConfusionMatrixChart Properties.

MATLAB

^{®}code generation is not supported for`ConfusionMatrixChart`

objects.

If you have Statistics and Machine Learning Toolbox™, you can create a confusion matrix chart for tall arrays. For details, see

`confusionchart`

(Statistics and Machine Learning Toolbox) and Confusion Matrix for Classification Using Tall Arrays (Statistics and Machine Learning Toolbox).