R中的3类AUC计算(pROC软件包) [英] 3-class AUC calculation in R (pROC package)

查看:885
本文介绍了R中的3类AUC计算(pROC软件包)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在R中遇到了3类ROC分析的问题,并获得了非常烦人的结果(请参阅

I met a problem of 3-class ROC analysis in R and obtained a very annoying result (see here). Now I try to use a different way to solve it. The data is iris and the classifier is multinomial logistic regression which is in nnet package. The code is below:

# iris data (3-class ROC)
library(nnet)
library(pROC) # should be installed first: install.packages('pROC')
data(iris)
# 3-class logistic regression
model = multinom(Species~., data = iris, trace = F)
# confusion matrix (z1) & accuracy (E1)
z1 = table(iris[, 5], predict(model, data = iris))
E1 = sum(diag(z1)) / sum(z1)
z1;E1
#             setosa versicolor virginica
#  setosa         50          0         0
#  versicolor      0         49         1
#  virginica       0          1        49
#[1] 0.9866667

# prediction model (still training data set)
pre = predict(model, data = iris, type='probs')
# AUC measure
modelroc = mean(
    c(as.numeric(multiclass.roc(iris$Species, pre[,1])$auc),
        as.numeric(multiclass.roc(iris$Species, pre[,2])$auc),
        as.numeric(multiclass.roc(iris$Species, pre[,3])$auc)
    )
)
modelroc
## RESULT ##
# [1] 0.9803556

我的问题是:
这是使用pROC软件包的正确方法吗?
非常感谢! 相关参考资料:
pROC软件包:
http://www.inside-r .org/packages/cran/pROC/docs/multiclass.roc
Hand & Till(2001)原始论文: http://link.springer.com/article/10.1023% 2FA%3A1010920819831

My question is:
Is this a right way of using pROC package?
Thanks a lot!!!

Some related reference:
pROC package: http://www.inside-r.org/packages/cran/pROC/docs/multiclass.roc
Hand & Till(2001) original paper: http://link.springer.com/article/10.1023%2FA%3A1010920819831

推荐答案

您将采用三个多类AUC的平均值,它们本身就是三个ROC曲线的AUC的平均值.因此,这就是9 AUC的平均值.根据您所遇到的实际问题,这可能不是您问题的正确答案,但是由于您从未问过,因此很难回答.我只能说的不是 Hand&您提到的Till(2001)论文.

You are taking the mean of three multiclass AUC, which are themselves the mean of the AUC of three ROC curves. So that's kind of the mean of 9 AUC. This might or might not be the right answer to your problem, depending on the actual question you have, but as you never asked it, it is quite difficult to answer. All I can say is, it's not what is described in the Hand & Till(2001) paper you mention.

这篇关于R中的3类AUC计算(pROC软件包)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆