How to calculate Percentage wise confusion matrix for each class??
13 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Abhipsa
on 19 Feb 2025
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!
0 Comments
See Also
Categories
Find more on Develop Apps Using App Designer 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!