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
댓글 수: 0
답변 (1개)
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!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!