Calculation of tp,tn,fp,fn for multi classes

조회 수: 5 (최근 30일)
asmi
asmi 2015년 3월 19일
답변: Greg Heath 2015년 3월 22일
Output=[1,1,1,-1,1,2,9,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,2,5,6,4,14,3,4]
Labels=[1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6]
from these values I have to calculate TP,TN,FP,FN..
  댓글 수: 3
asmi
asmi 2015년 3월 19일
TP= true positive,TN=True negative ,FP=false positive and FN=false negative .I have calculated this related to Face Recognition code.
asmi
asmi 2015년 3월 20일
I have calculated this parameter from 6 classes.(1,1,1,1,1) means it is one image like wise.Firstly I have to train the training data form feedforward neural network and getting that trained net I put the testing data and got these above output array.then match the labels and output matrix to calculate the tp,tn,fp,fn

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

채택된 답변

Greg Heath
Greg Heath 2015년 3월 22일
The standard approach for c classes is to use a target matrix of size [ c N ]that only contains columns of the matrix eye(c). The correspondence between the true class indices 1,2,...c and the target is
N = length(truclassindices)
target = ind2vec(truclassindices)
The assigned classes and corresponding errors are obtained from the net output via
output = net(input);
assignedclasses = vec2ind(output);
errors = assignedclasses~=truclassindices;
Nerr = sum(errors)
PctErr = 100*Nerr/N
[cm order] = confusionmat(target,output)
Hope this helps.
Thank you for formally accepting my answer
Greg

추가 답변 (1개)

Star Strider
Star Strider 2015년 3월 19일
I don’t understand your output. In theory, your classifier should assign one of the labels for each input (1-6), but your output contains classes such as -1, 9, and 14. That fails.
Anyway, when you get that problem sorted (and you must before you can go any further), see the documentation for confusionmat.

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by