IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
aggr_adaboost.m
Go to the documentation of this file.
1 %> @brief Adaboost
2 %>
3 %> @todo is there a way to make this testable as classifiers are added?
4 %>
5 %> Reference: Kuncheva, I. "Combining Patten Classifiers", Wiley, 2004.
6 %>
7 %> @sa uip_aggr_adaboost.m
8 classdef aggr_adaboost < aggr
9  properties
10  %> must contain a block object that will be replicated as needed
11  block_mold = [];
12  %> This SGS needs be a of class @c sgs_weighted
13  sgs;
14  %> Number of classifiers to be generated
15  no_clssrs = 10;
16  %> Coefficient to multiply weights by for misclassified samples
17  end;
18 
19  properties(SetAccess=protected)
20  % Weight updating coefficients per iteration
21  betas;
22  end;
23 
24  methods
25  function o = aggr_adaboost(o)
26  o.classtitle = 'Adaboost';
27  end;
28  end;
29 
30  methods(Access=protected)
31  % Adds classifiers when new classes are presented
32  function o = do_train(o, data)
33  if ~isa(o.sgs, 'sgs_weighted')
34  irerror('Invalid SGS: must be of class sgs_weighted or descendant!');
35  end;
36 
37  o.classlabels = data.classlabels;
38  osgs = o.sgs.setup(data);
39 
40  weights = ones(1, data.no);
41  de = decider();
42 
43  o.betas = zeros(1, o.no_clssrs);
44 
45  ipro = progress2_open('ADABOOST', [], 0, o.no_clssrs);
46  for i = 1:o.no_clssrs
47  osgs.weights = weights;
48  obsidxs = osgs.get_obsidxs_new();
49 
50  dtrain = data.split_map(obsidxs(1, 1));
51  cl = o.block_mold.boot();
52  cl = cl.train(dtrain);
53 
54  est = cl.use(data);
55  est = de.use(est);
56 
57  flags_missed = renumber_classes(est.classes, est.classlabels, data.classlabels) ~= data.classes;
58 
59  rateperc = sum(~flags_missed)/data.no;
60  beta = (1-rateperc)/(rateperc+realmin);
61  o.betas(i) = beta;
62 
63 
64  weights(~flags_missed) = weights(~flags_missed)*beta;
65 
66  o.blocks(i).block = cl;
67  o.blocks(i).classlabels = dtrain.classlabels;
68 
69  ipro = progress2_change(ipro, [], [], i);
70  end;
71  progress2_close(ipro);
72  end;
73  end;
74 end
75 
Base Sub-dataset Generation Specification (SGS) class.
Definition: sgs.m:6
function progress2_change(in prgrss, in title, in perc, in i, in n)
Base class for all ensemble classifiers.
Definition: aggr.m:6
Weighted Sub-Sampling.
Definition: sgs_weighted.m:5
function progress2_open(in title, in perc, in i, in n)
function irerror(in s)
Adaboost.
Definition: aggr_adaboost.m:8
Block that resolves estimato posterior probabilities into classes.
Definition: decider.m:10
Base Block class.
Definition: block.m:2
function progress2_close(in prgrss)
function renumber_classes(in classes_orig, in classlabels_orig, in classlabels_ref)
Analysis Session (AS) base class.
Definition: as.m:6