% MSVM_EXP1 Example on using the One-Against-All Decomposition.
%

% Modifications:
% 27-aug-2004, VF

% load data
% -------------------------------------------------------
data = load('pentagon');

% solve multi-clas SVM problem
% -------------------------------------------------------
options.ker = 'rbf';
options.arg = 1;
options.C = 1000;
options.verb = 1;

model = oaasvm(data,options);

% plot data and decision boundary (work for 2D data only)
% -------------------------------------------------------
figure;
ppatterns(data); ppatterns( model.sv.X, 'ok',13);
pboundary( model );

% displays binary classifiers
% -------------------------------------------------------
figure;
ppatterns(data,'num'); 

Handles = [];
Str = [];
cnt = 0;
for i=1:length(model.b),
  tmp_model = model;
  tmp_model.Alpha = model.Alpha(:,i);
  tmp_model.b = model.b(i);
  
  h = pboundary(tmp_model,{'line_style',['--' marker_color(i)]});
  if ~isempty(h),
    cnt = cnt + 1;
    Handles = [Handles, h(1)];
    Str{cnt} = sprintf('f_%d(x)',i);
  end
end
legend(Handles, Str);

% EOF
