4

我有二进制目标列表的预测分数。使用 R 或 matlab 计算精确召回曲线下面积的最佳方法是什么?

我对此进行了一些搜索,但没有找到任何相关的功能/库来完成这项任务。这似乎很奇怪,因为这应该是人们做的相当普遍的事情。不知道我是否错过了什么。任何帮助,将不胜感激。

4

1 回答 1

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));
于 2012-09-19T07:56:51.433 回答