필터 지우기
필터 지우기

How can I plot confusion matrix using the below code?

조회 수: 1 (최근 30일)
Biplab  Madhu
Biplab Madhu 2019년 7월 4일
답변: Yash Totla 2019년 7월 5일
function [confusion, accuracy, CR, FR] = confusion_matrix(class, c)
class = class.';
c = c.';
n = length(class);
c_len = length(c);
if n ~= sum(c)
disp('ERROR: wrong input!');
return;
end
% confusion matrix
confusion = zeros(c_len, c_len);
a = 0;
for i = 1: c_len
for j = (a + 1): (a + c(i))
confusion(i, class(j)) = confusion(i, class(j)) + 1;
end
a = a + c(i);
end
confusion = confusion';
% Correct_classification_rate + False_alarm_rate + Overall_accuracy
CR = zeros(1, c_len);
FR = zeros(1, c_len);
for i = 1: c_len
CR(i) = confusion(i, i)/sum(confusion(:, i));
FR(i) = (sum(confusion(i,:)) - confusion(i, i))/sum(confusion(i, :));
end
accuracy = sum(diag(confusion))/sum(c);
  댓글 수: 1
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 7월 4일
편집: KALYAN ACHARJYA 2019년 7월 4일
Thsi is a custom function, you have to pass the data to the function. Read about confusion matrix here.

댓글을 달려면 로그인하십시오.

답변 (1개)

Yash Totla
Yash Totla 2019년 7월 5일
There is a plotconfusion function in MATLAB Deep Learning Toolbox for plotting the confusion matrix.

카테고리

Help CenterFile Exchange에서 Mapping Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by