How to calculate true positive , true negative, false positive and false negative as we have segmented and ground truth

조회 수: 101 (최근 30일)
calculate true positive , true negative, false positive and false negative as we have segmented and ground truth is that code is correct idx = (expected()==1)
p = length( expected(idx)) n = length( expected(~idx)) N = p+n tp = sum( expected(idx)== predicted(idx)) tn = sum( expected(~idx)== predicted(~idx)) fp = n-tn fn = p-tp
accuracy=(tp+tn)/(tp+tn+fp+fn)

채택된 답변

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 9월 14일
편집: KALYAN ACHARJYA 2019년 11월 17일
%Last year I answered this way, you can avoid the loop (Recommended)
TP=0;FP=0;TN=0;FN=0;
for i=1:400;
for j=1:400;
if(gold_data(i,j)==1 & test_data(i,j)==1);
TP=TP+1;
elseif(gold_data(i,j)==0 & test_data(i,j)==1);
FP=FP+1;
elseif(gold_data(i,j)==0 & test_data(i,j)==0);
TN=TN+1;
else
FN=FN+1;
end
end
end
  댓글 수: 7

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by