% ADABOOST_EXP1 Example on AdaBoost.
%

% Modifications:
% 25-aug-2004, VF

% load training and testing data
% -------------------------------------------------------
trn_data = load('riply_trn');
tst_data = load('riply_tst');

% Training AdaBoost
% -------------------------------------------------------

options.learner = 'weak_learner2d';
options.max_rules = 200;
options.verb = 1;

model = adaboost(trn_data, options);

% Using AdaBoost for classification
ypred = adaclass(trn_data.X,model);
trnerr = cerror(ypred,trn_data.y)

ypred = adaclass(tst_data.X,model);
tsterr = cerror(ypred,tst_data.y)

% plot results
% -------------------------------------------------------
figure; ppatterns(trn_data); pboundary(model);
figure; hold on; xlabel('# of weak rules');
h1=plot(model.ErrBound); h2=plot(model.WeightedErr,'r');
legend([h1 h2],'Error bound','Weighted error');

% EOF