📄 svmroc.m
字号:
function [xsup,w,w0,pos,timeps,alpha,matriceind]=svmroc(x,y,C,kppv,margin,lambda,kernel,kerneloption,verbose,span,qpsize,kkttol,matriceind,alphainit);% USAGE% % [xsup,w,w0,pos,timeps,alpha,matriceind]=svmroc(x,y,C,kppv,margin,lambda,kernel,kerneloption,verbose,span,qpsize,matriceind)%%% SVM ROC Optimizer that can handle LS problem and large neighboorhood. This% algorithm uses a decomposition procedure.%% x y the learning data and labels% C penalization parameters% kppv the number of neighboor to consider. choose kppv=inf for% genuine ROC-SVM with no approx.% margin the margin for ranking% lambda conditioning parameter for the qp problem e.g 1e-7% kernel the kernel type e.g 'gaussian' or 'poly'% kerneloption kernel parameters% verbose verbosity of the algo 0 or 1% span type of semi parametric function e.g 1% qpsize size of qp algorithm%%% Outputs as usual for SVM except that xsup is a cell containing% the couple of positive and negative support vectors.% % see also svmrocval%% % 30/07/2004 A. Rakotomamonjyif nargin< 14 alphainit=[];end;if nargin< 13 matriceind=[];end;if nargin< 12 kkttol=1e-4;end;if size(alphainit,1)~=size(matriceind,1) error('matriceind and alphainit initialization size mismatch...');end;iteration=0;difftol=1e-7;chunksize=qpsize;indpos=find(y==1);indneg=find(y==-1);nbpos=length(indpos);nbneg=length(indneg);timeps=0;%-------------------------------------------------------------------------%% dist in feature space of each positive example to negative examples%% the idea here is to select a subset of couple for% optimizing the ranking%% % CASE 1 : select only the k-nearest negative neighbor of positive examplesif isempty(matriceind); if kppv~=inf for i=1:nbpos+nbneg norme2(i)=svmkernel(x(i,:),kernel,kerneloption); end; matriceindneg=[]; % select only the k-nearest positive neighbor of negative xamples for i=1:nbneg aux1=svmkernel(x(indneg(i),:),kernel,kerneloption,x(indpos,:)); dist=norme2(indneg(i))*ones(1,nbpos) + norme2(indpos) - 2*aux1 ; [aux,indicesorted]=sort(dist'); minim=min(length(indicesorted),kppv); matriceindneg=[matriceindneg; i*ones(minim,1) indicesorted(1:minim)]; end; vect=unique(matriceindneg(:,2)); % process only these couples of nn of these positive samples. dist=[]; matriceind=[]; for i=1:length(vect) aux1=svmkernel(x(indpos(vect(i)),:),kernel,kerneloption,x(indneg,:)); dist=norme2(indpos(vect(i)))*ones(1,nbneg) + norme2(indneg) - 2*aux1 ; [aux,indicesorted]=sort(dist'); minim=min(length(indicesorted),kppv); matriceind=[matriceind; vect(i)*ones(minim,1) indicesorted(1:minim)]; end; else % Select all couples % k=1; % for i=1:nbneg % for j=1:nbpos % matriceind(k,:)=[j i]; % k=k+1; % end; % end; [aux1 aux2] = meshgrid(1:nbpos,1:nbneg); [nn1,nn2]= size(aux1); matriceind = [reshape(aux1 ,nn1*nn2,1) reshape(aux2 ,nn1*nn2,1)]; end;end;taille=length(matriceind);%--------Matrice stocke la liste des couples de points
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -