📄 svmroccurve2.asv
字号:
function [AUC,tpr,fpr,b,WMW]=svmroccurve(xtest,ytest,xsup,w,w0,kernel,kerneloption,span)% USAGE%% [AUC,tpr,fpr,b]=svmroccurve(xtest,ytest,xsup,w,w0,kernel,kerneloption,span)%% process the ROC curve and the AUC for SVM model (either SVMROC or SVM L2) % % the inputs are as usual for SVM%% if nargin == 2 then the entries are% % [AUC,tpr,fpr,WMW,b]=svmroccurve(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];if nargin >2 ypred = svmrocval(xtest,xsup,w,w0,kernel,kerneloption,span);else ypred=xtest; w0=0;end;N=length(ypred);;b=[min(ypred)-1 ypred];for i=1:N+1; hi=sign(ypred-b(i)); [Conf,metric]=ConfusionMatrix(hi,ytest,classcode) tp(i)=C(1,1); fp(i)=C(2,1);end;npos=sum(ytest==classcode(1));tpr=tp/npos;fpr=fp/nneg;%WMW statisticsindpos=find(ytest==classcode(1));indneg=find(ytest==classcode(2));A=0;for i=1:npos A=A+ sum( (ypred(indpos(i))- ypred(indneg)) > eps); end;WMW=A/npos/nneg;AUC=WMW;% calcul de b pour un cout erreur egale
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -