matlab求曲线的面积 AUROC

本文介绍了在MATLAB中如何计算ROC曲线的面积以及一般曲线的面积,包括ROC曲线作为评估分类器性能指标AUROC的计算方法。
摘要由CSDN通过智能技术生成

曲线面积的求法:

(1)任意曲线的面积求法:

>> x=0:pi/100:pi;
>> y=sin(x);
>> trapz(x,y)

ans =

    1.9998

(2)ROC曲线的面积求法:

function auc=auc(FPR,TPR)
    % given true positive rate and false positive rate calculates the area under the curve
    % true positive are on the y-axis and false positives on the x-axis
    % sum rectangular area between all points
    % example: auc=auc(FPR,TPR);
    [x2,inds]=sort(FPR);
    x2=[x2,1];  % the trick is in inventing a last point 1,1
    y2=TPR(inds);
    y2=[y2,1];
    xdiff=diff(x2);
    %xdiff
    xdiff=[x2(1),xdiff];
    auc1=sum(y2.*xdiff); % upper point area
    auc2=sum([0,y2([1:end-1])].*xdiff); % lower point area
    auc=mean([auc1,auc2]);
end


  • 7
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值