How to use the 'perfcurve' of Matlab with specific inputs?
1 次查看(过去 30 天)
显示 更早的评论
Hi Smart guys,
I wrote following codes to get a plot of 'classification accuracy' vs. 'threshold':
(The datasets has the ground truth contains two classes labelled 'Good' or 'Bad')
LDAClassifierObject = ClassificationDiscriminant.fit(featureSelcted, groundTruthGroup, 'DiscrimType', 'linear');
[LDALabel, LDAScore] = resubPredict(LDAClassifierObject);
[~, AccuracyLDA, Thr] = perfcurve(groundTruthNumericalLable(:,1), LDAScore(:,1), 1,'yCrit','accu');
figure,
plot(Thr,AccuracyLDA,'r-');
hold on;
plot(Thr,AccuracyLDA,'bo');
xlabel('Threshold for ''good'' Returns');
ylabel('Classification Accuracy');
grid on;
[maxVal, maxInd] = max(AccuracyLDA)
maxVal =
0.8696
maxInd =
15
Thr(15)
ans =
0.7711
Also, I run the ROC analysis for the same datasets that the ground truth contains two classes labelled 'Good' or 'Bad'
[FPR, TPR, Thr, AUC, OPTROCPT] = perfcurve(groundTruthGroup(:,1), LDAScore(:,1), 'Good');
OPTROCPT =
0.1250 0.8667
Why Thr(15)=0.7711 is different from OPTROCPT(2)=0.8667 ?
Is the best cut-off point (ie, the best threshold OPTROCPT) obtained by ROC is the one has maximum accuracy of LDA?
Or maybe I am wrong, then what exactly `perfcurve(groundTruthNumericalLable(:,1), LDAScore(:,1), 1,'yCrit','accu')` tell us?
Thanks a lot.
A.
1 个评论
Ilya
2013-3-19
Why would any value in Thr be equal to any value in OPTROCPT? Could you copy and paste the part in the doc that made you believe these two should be equal?
回答(1 个)
Neil Caithness
2013-10-23
OPTROCPT(2) is the TPR value of the optimal cut-point, not the threshold value itself.
In your example, try
a = find(TPR==OPTROCPT(2))
One of these should be your index value 15, then
Thr(a)
should be your optimal threshold value 0.7711
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 ROC - AUC 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!