svoutput.m

来自「这是用matlab编的谱聚类程序」· M 代码 · 共 36 行

M
36
字号
function [fx]=svoutput(sv,svalpha,ker,bias,input)
%calcaulate the output of the svm after training with the input being input(variable)
%sv      --    the support vector after training
%svalpha --    the alpha corresponding the suppor vector
%ker     --    the type of kernel function,as follows:
%                   'linear'  -
%                   'poly'    - p1 is degree of polynomial
%                   'rbf'     - p1 is width of rbfs (sigma)
%                   'sigmoid' - p1 is scale, p2 is offset
%                   'spline'  -
%                   'bspline' - p1 is degree of bspline
%                   'fourier' - p1 is degree
%                   'erfb'    - p1 is width of rbfs (sigma)
%                   'anova'   - p1 is max order of terms
%bias    --    the bias gained after training
%input   --    the input in testing
%Author: Zhou Weida (Zhouwd@rsp.xidian.edu.cn)
if (nargin <2 | nargin>4) % check correct number of arguments   help svoutput
else
   m=size(input,1);
   fx=bias.*ones(m,1);
   n=size(sv,1);
   for k=1:1:m
      for j=1:1:n
         fx(k,1)=fx(k,1)+alpha(j,1)*svkernel(ker,input(k,:),sv(j,:))
      end
   end
   
end

         
      
     
    

⌨️ 快捷键说明

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