数模论坛

 找回密码
 注-册-帐-号
搜索
热搜: 活动 交友 discuz
查看: 2447|回复: 3

请大家帮我看看如下程序中一段语句的作用

[复制链接]
发表于 2005-1-22 00:53:04 | 显示全部楼层 |阅读模式
<>function [h] = svddplot(X,Y,ker,alpha,bias,aspect,mag,xaxis,yaxis,input)
%SVDDPLOT Support Vector Machine Plotting routine
%
%  Usage: svddplot(X,Y,ker,alpha,bias,zoom,xaxis,yaxis,input)
%
%  Parameters: X      - Training inputs
%              Y      - Training targets
%              ker    - kernel function
%              alpha  - Lagrange Multipliers
%              bias   - Bias term
%              aspect - Aspect Ratio (default: 0 (fixed), 1 (variable))
%              mag    - display magnification
%              xaxis  - xaxis input (default: 1)
%              yaxis  - yaxis input (default: 2)
%              input  - vector of input values (default: zeros(no_of_inputs))
%</P>
<>  if (nargin &lt; 5 | nargin &gt; 10) % check correct number of arguments
    help svcplot
  else</P>
<>    epsilon = 1e-5;  
    if (nargin &lt; 10) input = zeros(1,size(X,2));, end
    if (nargin &lt; 9) yaxis = 2;, end
    if (nargin &lt; 8) xaxis = 1;, end
    if (nargin &lt; 7) mag = 0.1;, end
    if (nargin &lt; 6) aspect = 0;, end
   
    % Scale the axes
    xmin = min(X(:,xaxis));, xmax = max(X(:,xaxis)); %平面中坐标轴x的最小值和最大值
    ymin = min(X(:,yaxis));, ymax = max(X(:,yaxis)); %平面中坐标轴y的最小值和最大值
    xa = (xmax - xmin);, ya = (ymax - ymin);   %坐标轴可表示区域</P>
<P>%%%%%%%%%%%%%%%%%%%%%%%%</P>
<P>%请问如下段是什么意思???谢谢!
    if (~aspect)
       if (0.75*abs(xa) &lt; abs(ya))   %有何意义?
          offadd = 0.5*(ya*4/3 - xa);,
          xmin = xmin - offadd - mag*0.5*ya;, xmax = xmax + offadd + mag*0.5*ya;
          ymin = ymin - mag*0.5*ya;, ymax = ymax + mag*0.5*ya;
       else
          offadd = 0.5*(xa*3/4 - ya);,
          xmin = xmin - mag*0.5*xa;, xmax = xmax + mag*0.5*xa;
          ymin = ymin - offadd - mag*0.5*xa;, ymax = ymax + offadd + mag*0.5*xa;
       end
    else
       xmin = xmin - mag*0.5*xa;, xmax = xmax + mag*0.5*xa;
       ymin = ymin - mag*0.5*ya;, ymax = ymax + mag*0.5*ya;
    end</P>
<P>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    set(gca,'XLim',[xmin xmax],'YLim',[ymin ymax]);  </P>
<P>    % Plot function value</P>
<P>    [x,y] = meshgrid(xminxmax-xmin)/50:xmax,yminymax-ymin)/50:ymax);
    z = bias*ones(size(x));
    wh = waitbar(0,'Plotting...');
    for x1 = 1 : size(x,1)
      for y1 = 1 : size(x,2)
        input(xaxis) = x(x1,y1);, input(yaxis) = y(x1,y1);
        for i = 1 : length(Y)
          if (abs(alpha(i)) &gt; epsilon)
         z(x1,y1) = z(x1,y1) + Y(i)*alpha(i)*svkernel(ker,input,X(i,);
          end
        end
      end
      waitbar((x1)/size(x,1))
    end
    close(wh)
    l = (-min(min(z)) + max(max(z)))/2.0;
    sp = pcolor(x,y,z);
    shading interp  
    set(sp,'LineStyle','none');
    set(gca,'Clim',[-l  l],'Position',[0 0 1 1])
    axis off
    load cmap
    colormap(colmap)</P>
<P>    % Plot Training points</P>
<P>    hold on
    for i = 1:size(Y)
      if (Y(i) == 1)
        h(1) = plot(X(i,xaxis),X(i,yaxis),'b+','LineWidth',4); % Class A
      else
        h(2) = plot(X(i,xaxis),X(i,yaxis),'r+','LineWidth',4); % Class B
      end
      if (abs(alpha(i)) &gt; epsilon)
        plot(X(i,xaxis),X(i,yaxis),'wo') % Support Vector
      end
    end </P>
<P>    % Plot Boundary contour</P>
<P>    hold on
    contour(x,y,z,[0 0],'w')
    contour(x,y,z,[-1 -1],'w:')
    contour(x,y,z,[1 1],'w:')
    hold off</P>
<P>  end   
</P>
发表于 2005-1-27 20:51:20 | 显示全部楼层
<>呵呵</P><>你能不能说说 让大家理解一下</P>
发表于 2005-1-29 21:16:11 | 显示全部楼层
呵呵,太长了啊!
发表于 2005-2-4 16:54:38 | 显示全部楼层
<>晕~~~~~~</P>
您需要登录后才可以回帖 登录 | 注-册-帐-号

本版积分规则

小黑屋|手机版|Archiver|数学建模网 ( 湘ICP备11011602号 )

GMT+8, 2024-11-27 20:38 , Processed in 0.054674 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表