svmmulticlassoneagainstall.m

来自「支持向量机的开发软件包,里面有几个例子,很好用的!」· M 代码 · 共 59 行

M
59
字号
function [xsup,w,b,nbsv,pos]=svmmulticlass(x,y,nbclass,c,epsilon,kernel,kerneloption,verbose);

% USAGE [xsup,w,b,nbsv,pos]=svmmulticlass(x,y,nbclass,c,epsilon,kernel,kerneloption,verbose);
%
%
% SVM Multi Classes Classification One against Others algorithm
%
% y is the target vector which contains integer from 1 to nbclass.
% 
% This subroutine use the svmclass function
% 
% the differences lies in the output nbsv which is a vector
% containing the number of support vector for each machine
% learning.
% For xsup, w, b, the output of each ML are concatenated
% in line.
% 
% 
% See svmclass, svmmultival
%
%
% 29/07/2000 Alain Rakotomamonjy

xsup=[];  % 3D matrices can not be used as numebr of SV changes
w=[];
b=[];
pos=[];
nbsv=zeros(1,nbclass);
nbsuppvector=zeros(1,nbclass);
if isstruct(x)
    xsup=x;
end;
for i=1:nbclass
    
    yone=(y==i)+(y~=i)*-1;
    

    [xsupaux,waux,baux,posaux]=svmclassls(x,yone,c,epsilon,kernel,kerneloption,verbose);
    
    
    if ~isstruct(x)  % data is stored in matrix
        [n1,n2]=size(xsupaux);
        nbsv(i)=n1;
        xsup=[xsup;xsupaux];
        w=[w;waux];
        b=[b;baux];
        pos=[pos;posaux];
    else % data is stored in file
        w=[w;waux];
        b=[b;baux];
        pos=[pos;posaux];
        nbsv(i)=length(posaux);
        
        xsup.indice=x.indice(pos);
    end;
end;


⌨️ 快捷键说明

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