How to plot confusion matrix for for multi classes

18 次查看(过去 30 天)
Hi friends,
I have a confusionmatrix as follows:
X=
[ 6 1 0 0
0 6 0 1
0 0 7 1
1 0 0 5 ]
I want to plot the confusion matrix In a 100 % percentage form such (85.0% ), and lable the classes, but i faced some problems.
i used the following code:
A=[6 1 0 0 ;0 6 0 1; 0 0 7 1;1 0 0 5];
M = confusionchart(A)
M.RowSummary = 'row-normalized';
M.ColumnSummary = 'column-normalized';
h = gca;
h.XTickLabel = {' A',' B',' C','D', ''};
h.YTickLabel = {' A',' B',' C','D',''};
I want to have the same with plot below.
Any help will be highly appreciated

采纳的回答

Srivardhan Gadila
Srivardhan Gadila 2021-3-22
The above confusion matrix chart can only be obtained using the function plotconfusion(targets,outputs) which requires true labels targets and predicted labels outputs, specified as categorical vectors, or in one-of-N (one-hot) form.
Since you have confusion matrix already, you cannot use the above function and can only use confusionchart function.
If you are looking only for the percentages to have in the chart then you can use the Normalization Name-Value Pair argument and set it to 'total-normalized' or 'row-normalized' or 'column-normalized'.
A=[6 1 0 0 ;0 6 0 1; 0 0 7 1;1 0 0 5];
M = confusionchart(A,{' A',' B',' C','D'},'Normalization','total-normalized')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Classification 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by