Matlab函数perfcurve错误地断言ROC AUC = 1

时间:2016-10-14 13:34:47

标签: matlab roc

Matlab中的perfcurve函数错误地说,当两个记录明显错误分类为合理的截止值时,断言AUC = 1。 如果我通过带有截止0.5的混淆矩阵运行相同的数据,则精度恰好低于1。 MWE包含来自我的一个折叠的数据。我注意到了这个问题,因为我在结果中看到了完美的auc,而且准确性不够理想。

我使用Matlab 2016a和Ubuntu 16.4 64bit。

% These are the true classes in one of my test-set folds
classes = transpose([ones(1,9) 2*ones(1,7)])
% These are predictions from my classifier
% Class 1 is very well predicted
% Class 2 has two records predicted as class 1 with threshold 0.5
confidence = transpose([1.0 1.0 1.0 1.0 0.9999 1.0 1.0...
    1.0 1.0 0.0 0.7694 0.0 0.9917 0.0 0.0269 0.002])
positiveClass = 1
% Nevertheless, the AUC yields a perfect 1
% I understand why X, Y, T have less values than classes and confidence
% Identical records are dealt with by one point on the ROC curve
[X,Y,T,AUC] = perfcurve(classes, confidence, positiveClass)
% The confusion matrix for comparison
threshold = 0.5
confus = confusionmat(classes,(confidence<threshold)+1)
accuracy = trace(confus)/sum(sum(confus))

1 个答案:

答案 0 :(得分:0)

这仅仅意味着另一个截止,其中分离是完美的。

尝试:

threshold = 0.995
confus = confusionmat(classes,(confidence<threshold)+1)
accuracy = trace(confus)/sum(sum(confus))