IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
aggr.m
Go to the documentation of this file.
1 %> @brief Base class for all ensemble classifiers
2 %>
3 %> Multiple Training-compatible
4 %>
5 %> @sa uip_aggr.m
6 classdef aggr < clssr
7  properties
8  %> =esag_linear1. Estimation Aggregator object
9  esag = esag_linear1();
10  %> =0. Whether to record the estimations of the component classifiers into the object (@c o ) itself in the @c do_use() method.
11  flag_ests = 0;
12  end;
13 
14  properties
15  %> (Read-only) @c estimato objects carried out of @c do_use() if @c flag_ests is true
16  ests;
17  %> (Read-only) Structure array with fields @c block and @c classlabels
18  blocks;
19  end;
20 
21  methods
22  function o = aggr(o)
23  o.classtitle = 'Ensemble';
24  end;
25 
26  function o = add_clssr(o, cl)
27  nb = numel(o.blocks);
28  o.blocks(nb+1).block = cl;
29  o.blocks(nb+1).classlabels = cl.classlabels;
30  o.classlabels = union(o.classlabels, cl.classlabels);
31  end;
32 
33 % % % TODO not sure about this, gotta see where used, then find solution
34 % % function z = getbatch(o, propname)
35 % % no_mod = length(a.blocks);
36 % % % initializes output
37 % % out = 0;
38 % %
39 % % for m = 1:no_mod
40 % % eval(sprintf('out = out+a.blocks{%d}.%s;', m, propname));
41 % % end;
42 % % end
43  end;
44 
45  methods(Access=protected)
46 
47  %> Deletes all components and creates default @ref aggr::esag if needed
48  function o = do_boot(o)
49  o.blocks = struct('block', {}, 'classlabels', {});
50  if isempty(o.esag)
51  o.esag = esag_linear1();
52  end;
53  end;
54 
55  %> Default training passes same dataset to each block.
56  function o = do_train(o, data)
57  nb = numel(o.blocks);
58  for i = 1:nb
59  o.blocks{i}.block = o.blocks{i}.block.train(data);
60  end;
61  end;
62 
63  %> Uses blocks and aggregates @c est 's using @c o.esag
64  %>
65  %> @retval [o, est]
66  function est = do_use(o, data)
67 
68  nb = numel(o.blocks);
69  for i = 1:nb
70  [o.blocks(i).block, ests_(i)] = o.blocks(i).block.use(data);
71  ests_(i) = ests_(i).change_classlabels(o.classlabels);
72  end;
73 
74  est = o.esag.use(ests_);
75  if o.flag_ests
76  o.ests = ests_;
77  else
78  o.ests = [];
79  end;
80  end;
81  end;
82 end
Base class for all ensemble classifiers.
Definition: aggr.m:6
Estimation Aggregator - combines estimato objects together.
Definition: esag.m:2
Estimation Aggregator - Linear Combination of datasets.
Definition: esag_linear1.m:2
Base Block class.
Definition: block.m:2
Classifiers base class.
Definition: clssr.m:6
Dataset representing estimation.
Definition: estimato.m:4