【问题标题】:pROC multiclass.roc - univariate case. How is AUC calculated in this instance?pROC multiclass.roc - 单变量案例。在这种情况下如何计算 AUC?
【发布时间】:2019-07-17 22:13:29
【问题描述】:

很清楚 Hand 和 Till 方法在多变量情况下是如何工作的(根据类概率),我已经对照我编写的一些代码检查了这一点。 IE。我使用了一个 3 类问题,我得到了与 pROC 相同的结果。当我将 3 类问题转换为 2 类问题(通过合并 2 个类)时,我得到与 pROC 相同的结果(仍然使用 multiclass.roc)。但是,当我通过 multiclass.roc 响应具有 3 个类、3 个级别但只有一个类概率向量时,我得到了另一个结果。

我知道处理方式不同; https://rdrr.io/cran/pROC/man/multiclass.html 说“multiclass.roc 函数可以处理两种类型的数据集:单变量和多变量。在单变量情况下,传递单个预测向量并评估所有响应组合。”。但是,我无法找到关于这里发生的事情的解释。显然这与响应中的类数量有关(因为这是唯一的其他数据),但我很想知道在这种情况下 pROC 正在做什么。

这是我的结果(我写了 AUC_mc):

pROC:3 类单变量:0.8494,3 类与其他(2 类):0.9118
AUC_mc:3 级与其他(2 级):0.9118

pROC:1 类单变量:0.9721,1 类与其他(2 类):0.9693
AUC_mc:1 类与其他类(2 类):0.9692823

#
# Here the probabilities for only 1 class are passed to pROC.   
# When there are 2 classes in the domain that's fine  
# When there are 3 classes in the domain then I get a different result
#
roc = multiclass.roc(test.df$response, probabilities[,n], levels=levels(test.df$response))

pROC:3 类:0.9568
AUC_mc:3类:0.9567698

roc = multiclass.roc(test.df$response, probabilities[,], levels=levels(test.df$response))

非常感谢

【问题讨论】:

  • 嗨,约翰,欢迎来到 Stack Overflow。您能否发布生成您看到的结果的代码?如果您发布代码,您更有可能得到有用的回复。

标签: proc-r-package


【解决方案1】:

在单变量情况下,pROC 测试所有 1 对 1 比较。其余的比较没有 1。因此,对于 3 个类,您有 3 条 roc 曲线:1 对 2; 1对3;和 2 对 3。

你可以找到the source code in multiclass.R:

rocs <- utils::combn(levels, 2, function(X, response, predictor, percent, ...) {
    roc(response, predictor, levels=X, percent=percent, auc=FALSE, ci=FALSE, ...)
[...]

utils::combn 函数一次生成levels 的元素的所有组合2

我会尝试改进文档以更好地反映这一点。

【讨论】:

    猜你喜欢
    • 2017-04-29
    • 2019-06-13
    • 2019-10-31
    • 2018-12-26
    • 1970-01-01
    • 2016-11-18
    • 1970-01-01
    • 1970-01-01
    • 2020-04-17
    相关资源
    最近更新 更多