How to plot confusion matrix for for multi classes
18 views (last 30 days)
Show older comments
Abdulhakim Alezzi
on 19 Mar 2021
Commented: Abdulhakim Alezzi
on 22 Mar 2021
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
0 Comments
Accepted Answer
Srivardhan Gadila
on 22 Mar 2021
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')
More Answers (0)
See Also
Categories
Find more on Classification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!