How to plot confusion matrix for for multi classes

18 visualizaciones (últimos 30 días)
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

Respuesta aceptada

Srivardhan Gadila
Srivardhan Gadila el 22 de Mzo. de 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')

Más respuestas (0)

Categorías

Más información sobre Classification en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by