【问题标题】:Matlab function perfcurve falsely asserts ROC AUC = 1Matlab 函数 perfcurve 错误地断言 ROC AUC = 1
【发布时间】: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))

【问题讨论】:

    标签: matlab roc


    【解决方案1】:

    这仅仅意味着存在另一个分界线,其中的分离是完美的。

    试试:

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

    【讨论】:

    • 但是 roc 无论如何都会在截止点上执行扫描。因此,如果您在控制台上查看 X、Y 和 T 的输出例如:0.9917 0.7694
    • @user7019377 它扫描了所有可能的截止点,发现其中一个具有完美的分离度,因此您得到 AUC = 1。
    • 例如 T 中 0.9917 和 0.7694 的阈值将导致将这些 2 类示例分类为 1 类。然而 Y 表示完美的 TPR(特异性),而 X 表示没有 FPR(完美的灵敏度)。 (不小心按了太快,因为我是新来的,所以找不到编辑按钮。)
    • 我现在看到了,只是不确定这是否是我想要的。但这不是我想的 Roc 曲线的错。
    • 这可能不是你想要的,但 Matlab 说 AUC = 1 是正确的。
    猜你喜欢
    • 2019-08-27
    • 1970-01-01
    • 2014-07-04
    • 2020-02-23
    • 2019-08-15
    • 2017-10-25
    • 2019-03-04
    • 2019-06-09
    • 1970-01-01
    相关资源
    最近更新 更多