www.gusucode.com > 支持向量机的Matlab实现,支持多分类,据有GUI操作界面 > code11/MATLAB_svm_gui/function/oaosvm.txt

    1.oaosvm.m
% OAOSVM Multi-class SVM using One-Against-One decomposition.
% 
% Synopsis:
%  model = oaosvm( data )
%  model = oaosvm( data, options )
%
% Description:
%  model = oaosvm( data ) uses one-agains-one deconposition
%   to train the multi-class Support Vector Machines (SVM)
%   classifier. The classification into nclass classes 
%   is decomposed into nrule = (nclass-1)*nclass/2 binary 
%   problems.
%
%  model = oaosvm( data, options) allows to specify the
%   binary SVM solver and its paramaters.
%
% Input:
%  data [struct] Training data:
%   .X [dim x num_data] Training vectors.
%   .y [1 x num_data] Labels of training data (1,2,...,nclass). 
%
%  options [struct] Control parameters:
%   .solver [string] Function which implements the binary SVM 
%     solver; (default 'smo').
%   .verb [1x1] If 1 then a progress info is displayed (default 0).
%  The other fileds of options specifies the options of the binary
%  solver (e.g., ker, arg, C). See help of the selected solver.
%
% Output:
%  model [struct] Multi-class SVM majority voting classifier:
%   .Alpha [nsv x nrule] Weights (Lagrangeans).
%   .bin_y [2 x nrule] Translation between binary responses of
%     the discriminant functions and class labels.
%   .b [nrule x 1] Biases of discriminant functions.
%   .sv.X [dim x nsv] Support vectors.
%   .nsv [1x1] Number of support vectors.
%   .trnerr [1x1] Training error.
%   .kercnt [1x1] Number of kernel evaluations.
%   .options [struct[ Copy of input argument options.
%
% Example:
%  data = load('pentagon');
%  options = struct('ker','rbf','arg',1,'C',1000,'verb',1);
%  model = oaosvm( data, options );
%  figure; 
%  ppatterns(data); ppatterns(model.sv.X,'ok',13);
%  pboundary( model );
%  
% See also 
%  MVSVMCLASS, OAASVM.
%

% About: Statistical Pattern Recognition Toolbox
% (C) 1999-2003, Written by Vojtech Franc and Vaclav Hlavac
% <a href="http://www.cvut.cz">Czech Technical University Prague</a>
% <a href="http://www.feld.cvut.cz">Faculty of Electrical Engineering</a>
% <a href="http://cmp.felk.cvut.cz">Center for Machine Perception</a>

% Modifications:
% 26-may-2004, VF
% 4-feb-2004, VF
% 9-Feb-2003, VF

% Process inputs

2.ppatterns.m

% PPATTERNS Plots pattern as points in feature space.
% 
% Synopsis:
%  ppatterns(data,marker_size)
%  ppatterns(data,'num')
%  ppatterns(X,marker,marker_size)
%  ppatterns(X,y)
%  ppatterns(X,y,marker_size)
%  ppatterns(X,y,'num')
%
% Description:
%  ppatterns(data,marker_size) plots data.X as points
%   distinguished by marker and its color according to 
%   given labels data.y. The marker size can be prescribed.
%
%  ppatterns(data,'num') plots data.X in distinguished 
%   by numbers and colors according to given labels data.y. 
%   The marker size can be determined by argument marker_size.
%
%  ppatterns(X,marker,marker_size) plots data X. Marker type
%   can be determined by argument marker. The marker size can 
%   be determined by argument marker_size.
%
%  ppatterns(X,y,...) instead of structure data, which contains
%   items X and y these can enter the function directly.
%
%  If dimension of input data is greater than 3 then
%  only first 3 dimensions are assumed and data are plotted 
%  in 3D space.
%
% Output:
%  H [struct] Handles of used graphical objects.
%
% Example:
%  data = load('riply_trn');  
%  figure; ppatterns(data);
%  figure; ppatterns(data,'num');
%  figure; ppatterns(data.X,'xk',10);
%  
% See also 
%  PLINE.
%

% About: Statistical Pattern Recognition Toolbox
% (C) 1999-2003, Written by Vojtech Franc and Vaclav Hlavac
% <a href="http://www.cvut.cz">Czech Technical University Prague</a>
% <a href="http://www.feld.cvut.cz">Faculty of Electrical Engineering</a>
% <a href="http://cmp.felk.cvut.cz">Center for Machine Perception</a>

% Modifications:
% 25-may-2004, VF
% 11-mar-2004, VF, 
% 5-oct-2003, VF, returns handles
% 12-feb-2003, VF, 1D, 3D added
% 7-jan-2003, VF, created