Effacer les filtres
Effacer les filtres

How to plot confusion matrix for for multi classes

36 vues (au cours des 30 derniers jours)
Abdulhakim Alezzi
Abdulhakim Alezzi le 19 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

Réponse acceptée

Srivardhan Gadila
Srivardhan Gadila le 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')

Plus de réponses (0)

Catégories

En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by