soutput.m

来自「支持向量机 这是我的老师编写的matlab源文件 希望对大家有用」· M 代码 · 共 37 行

M
37
字号
function [fx]=soutput(sv,svy,svalpha,ker,bias,input)
%[fx]=svoutput(sv,svy,svalpha,ker,bias,input)
%calcaulate the output of the svm after training with the input being input(variable)
%sv      --    the support vector after training
%svy     --    the expect output in 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
if (nargin <2 | nargin>6) % 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)+svalpha(j,1)*svy(j,1)*svkernel(ker,input(k,:),sv(j,:));
      end
   end
   
end

         
      
     
    

⌨️ 快捷键说明

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