我有二进制目标列表的预测分数。使用R或matlab计算精确回忆曲线下面积的最佳方法是什么?
我对此进行了一些搜索,并没有找到任何相关函数/库来完成此任务。这看起来很奇怪,因为这应该是人们相当普遍的事情。不确定我是否遗漏了什么。任何帮助将不胜感激。
答案 0 :(得分:1)
下面是matlab实现
function auc = scoreAUC(category,posterior)
% auc = scoreAUC(category,posterior)
%
% Calculates the area under the ROC for a given set
% of posterior predictions and labels. Currently limited to two classes.
%
% posterior: n1 matrix of posterior probabilities for class 1
% category: n1 matrix of categories {0,1}
% auc: Area under the curve
%
% Author: Benjamin Hamner
% Date Modified: October 14, 2010
%
% Algorithm found in
% A Simple Generalisation of the Area Under the ROC
% Curve for Multiple Class Classification Problems
% David Hand and Robert Till
% http://www.springerlink.com/content/nn141j42838n7u21/fulltext.pdf
r = tiedrank(posterior);
auc = (sum(r(category==1)) - sum(category==1) * (sum(category==1)+1)/2) / ...
( sum(category<1) * sum(category==1));