How to calculate Percentage wise confusion matrix for each class??

9 次查看(过去 30 天)
I have tried the following command to calculate the confusion matrix
C = confusionmat(testinglabels,predictedLabels)
It gave me the result as shown in the attachment
I want to calculate percentage wise confusion matrix for each class
Please help me

回答(1 个)

Abhipsa
Abhipsa 2025-2-19
When using “confusionmat”, the output is given in terms of the number of instances. To express the results as percentages, you can normalize the confusion matrix.
% Normalize the confusion matrix to get percentages
rowSums = sum(C, 2); % Sum of each row
percentageC = (C ./ rowSums) * 100 %this is the result in percentage
Additionally, if you are using MATLAB R2018b or a later version, you can utilise the “confusionchart” function with the “Normalization” name-value pair to achieve this result.
You can read more about “confusionchart” using the follwing MATLAB command:
>> doc confusionchart
I hope this helps!

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by