计算R中的AUC? [英] Calculate AUC in R?

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

问题描述

给出分数向量和实际类别标签向量,如何为R语言或简单英语中的二进制分类器计算单数AUC度量?

Given a vector of scores and a vector of actual class labels, how do you calculate a single-number AUC metric for a binary classifier in the R language or in simple English?

"AUC:更好的措施..."的第9页似乎需要了解类标签,这是 MATLAB中的示例我不理解

Page 9 of "AUC: a Better Measure..." seems to require knowing the class labels, and here is an example in MATLAB where I don't understand

R(Actual == 1))

因为R(不要与R语言混淆)被定义为向量而是用作函数?

Because R (not to be confused with the R language) is defined a vector but used as a function?

推荐答案

如其他人所述,您可以使用

As mentioned by others, you can compute the AUC using the ROCR package. With the ROCR package you can also plot the ROC curve, lift curve and other model selection measures.

您可以通过使用AUC等于将真实正值得分大于真实负值的概率这一事实来直接计算AUC,而无需使用任何程序包.

You can compute the AUC directly without using any package by using the fact that the AUC is equal to the probability that a true positive is scored greater than a true negative.

例如,如果pos.scores是包含阳性示例分数的矢量,而neg.scores是包含阴性示例分数的矢量,则AUC近似为:

For example, if pos.scores is a vector containing a score of the positive examples, and neg.scores is a vector containing the negative examples then the AUC is approximated by:

> mean(sample(pos.scores,1000,replace=T) > sample(neg.scores,1000,replace=T))
[1] 0.7261

将给出AUC的近似值.您还可以通过自举来估算AUC的方差:

will give an approximation of the AUC. You can also estimate the variance of the AUC by bootstrapping:

> aucs = replicate(1000,mean(sample(pos.scores,1000,replace=T) > sample(neg.scores,1000,replace=T)))

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

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