⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rankroccurve.m

📁 一个支持向量机的matlab工具箱
💻 M
字号:
function [AUC,tpr,fpr,b]=rankroccurve(ypred,ytest)% USAGE%% [AUC,tpr,fpr,WMW,b]=rankroccurve(ypred,ytest)%% the outputs%% AUC       Area under curve value% tpr,fpr   true positive and false positive vector for ROC curve plotting purpose% b         a new bias for the decision function. b can replace w0 and it has been%           processed so that the decision function corresponds to the one where the roc%            curve and the (1,0)-(0,1) diagonal meets%% 30/07/2004 A. Rakotomamonjyeps=1e-7;classcode=[1 -1];w0=0;ypredsorted=sort(ypred);npos=length(find(ytest==classcode(1)));nneg=length(find(ytest==classcode(2)));n=npos+nneg;  i=1;b=ypredsorted(1);yaux=ypred-b+eps;C=ConfusionMatrix(sign(yaux),ytest,classcode);tp(i)=C(1,1);fp(i)=C(2,1);for i=1:n    b=ypredsorted(i);    yaux=ypred-b;    C=ConfusionMatrix(sign(yaux),ytest,classcode);    tp(i+1)=C(1,1);    fp(i+1)=C(2,1);end;yaux=ypred-b-eps;C=ConfusionMatrix(sign(yaux),ytest,classcode);tp(i+2)=C(1,1);fp(i+2)=C(2,1);tpr=tp/npos;fpr=fp/nneg;difffpr=-diff(fpr);AUC=sum(tpr(1:end-1).*difffpr);%% WMW statistics% indpos=find(ytest==classcode(1));% indneg=find(ytest==classcode(2));% A=0;% for i=1:npos%     A=A+ sum( ypred(indpos(i))> ypred(indneg));%     % end;% WMW=A/npos/nneg;% calcul de b pour un cout erreur egale 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -