%% Create Confusion Matrix Chart
% Load a sample of predicted and true labels for a classification problem. trueLabels is the true labels for an image classification problem and predictedLabels is the predictions of a convolutional neural network.

load('Cifar10Labels.mat','trueLabels','predictedLabels');

% Create a confusion matrix chart.

figure
cm = confusionchart(trueLabels,predictedLabels);

%
%
% Modify the appearance and behavior of the confusion matrix chart by changing property values. Add column and row summaries and a title. A column-normalized column summary displays the number of correctly and incorrectly classified observations for each predicted class as percentages of the number of observations of the corresponding predicted class. A row-normalized row summary displays the number of correctly and incorrectly classified observations for each true class as percentages of the number of observations of the corresponding true class.

cm.ColumnSummary = 'column-normalized';
cm.RowSummary = 'row-normalized';
cm.Title = 'CIFAR-10 Confusion Matrix';

% Copyright 2018 The MathWorks, Inc.