confusionchart
Create confusion matrix chart for classification problem
Syntax
Description
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 x-axis and y-axis. Use this syntax if you already have a numeric confusion matrix and class labels in the workspace.m
,classLabels
)
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.
Examples
Input Arguments
Output Arguments
Limitations
MATLAB® code generation is not supported for
ConfusionMatrixChart
objects.
More About
Tips
If you have one-hot (one-of-N) data, use
onehotdecode
to prepare your data for use withconfusionchart
. For example, suppose you have true labelstargets
and predicted labelsoutputs
, with observations in columns. You can create a confusion matrix chart usingnumClasses = size(targets,1); trueLabels = onehotdecode(targets,1:numClasses,1); predictedLabels = onehotdecode(outputs,1:numClasses,1); confusionchart(trueLabels,predictedLabels)
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).
Version History
Introduced in R2018b