svmmultival.m

来自「用于matlab环境下的支持向量机svm的工具箱」· M 代码 · 共 37 行

M
37
字号
function [ypred,maxi]=svmmultival(x,xsup,w,b,nbsv,kernel,kerneloption)

% USAGE ypred=svmmultival(x,xsup,w,b,nbsv,kernel,kerneloption)
% 
% Process the class of a new point x of a one-against-all 
% or a all data at once MultiClass SVM
% 
% This function should be used in conjuction with the output of
% svmmulticlass.
%
%
% See also svmmulticlass, svmval
%

% 29/07/2000 Alain Rakotomamonjy


[n1,n2]=size(x);
nbclass=length(nbsv);
y=zeros(n1,nbclass);
nbsv=[0 nbsv];
aux=cumsum(nbsv);
for i=1:nbclass
    if ~isstruct(xsup)
         xsupaux=xsup(aux(i)+1:aux(i)+nbsv(i+1),:);
        waux=w(aux(i)+1:aux(i)+nbsv(i+1));
        baux=b(i);
    else
        xsupaux=xsup;
        xsupaux.indice=xsup.indice(aux(i)+1:aux(i)+nbsv(i+1));
        waux=w(aux(i)+1:aux(i)+nbsv(i+1));
        baux=b(i);
    end;
   ypred(:,i)= svmval(x,xsupaux,waux,baux,kernel,kerneloption);
end;
[maxi,ypred]=max(ypred');

⌨️ 快捷键说明

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