IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
aggr_bag.m
Go to the documentation of this file.
1 %> @brief Bagging ensemble.
2 %>
3 %> Each time the classifier is trained, several component classifiers will be generated. The number of components and how their
4 %> respective training data are obtained are specified by the @c sgs property.
5 %>
6 %> Allows multi-training.
7 %>
8 %> Can be used for undersampling. Use an sgs_randsub with balanced properties.
9 classdef aggr_bag < aggr
10  properties
11  %> must contain a block object that will be replicated as needed
12  block_mold = [];
13  %> SGS to do the bagging. Doesn't need to be a sgs_randsub one, actually. K-fold will work, too.
14  sgs;
15  end;
16 
17  methods
18  function o = aggr_bag()
19  o.classtitle = 'Bagging';
20  end;
21  end;
22 
23  methods(Access=protected)
24  function o = do_boot(o)
25  o = do_boot@aggr(o);
26  end;
27 
28  % Adds classifiers when new classes are presented
29  function o = do_train(o, data)
30  obsidxs = o.sgs.get_obsidxs(data);
31  no_reps = size(obsidxs, 1);
32 
33 % ipro = progress2_open('BAGGING', [], 0, no_reps);
34  for i_rep = 1:no_reps
35  datasets = data.split_map(obsidxs(i_rep, 1));
36 
37  cl = o.block_mold.boot();
38  cl = cl.train(datasets(1));
39  o = o.add_clssr(cl);
40 % ipro = progress2_change(ipro, [], [], i_rep);
41  end;
42 % progress2_close(ipro);
43 
44  end;
45  end;
46 end
Base Sub-dataset Generation Specification (SGS) class.
Definition: sgs.m:6
Base class for all ensemble classifiers.
Definition: aggr.m:6
Base Block class.
Definition: block.m:2
Bagging ensemble.
Definition: aggr_bag.m:9
Random Sub-sampling.
Definition: sgs_randsub.m:5
Analysis Session (AS) base class.
Definition: as.m:6