【发布时间】:2017-02-23 23:11:00
【问题描述】:
Matlab 中的 perfcurve 函数错误地断言 AUC=1 当两条记录明显错误分类为合理的截止值时。 如果我通过一个截止值为 0.5 的混淆矩阵运行相同的数据,则准确度正好低于 1。 MWE 包含来自我的一个折叠的数据。我注意到了这个问题,因为我在结果中看到了完美的 auc,但准确性并不完美。
我使用 Matlab 2016a 和 Ubuntu 16.4 64 位。
% 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))
【问题讨论】: