1 %> @brief Hierarchical split
3 %> Feeds blocks with successive sub-datasets obtaining by splitting @c data
using the @c hie_split
class levels
6 %> The classifiers in the @c clssrs
property must be multi-trainable (recommended: @ref aggr_free).
7 %> The classifiers must <b>not</b> be of
class @c
aggr_hiesplit.
9 %> @todo Temporaritly deactivated. This may be obsolete. There is
new dataset
property instead of
this hie_split/hie_classify pair
11 %> @sa uip_reptt_hiesplit.m, demo_reptt_hiesplit.m
14 %> Number of repetitions. Each repetition corresponds to a random permutation of the order with which the
15 %> sub-datasets are given to the classifier.
17 %> =1 . Class levels to use at splitting the dataset
19 %> =2 . Class levels to use at selecting the relevant classes
for classification
21 %>
if > 0, MATLAB
's rand('twister
', o.randseed) will be called before. This can be used to repeat sequences.
27 properties(Access=protected)
32 function o = reptt_hiesplit(o)
33 o.classtitle = 'Class-Hierarchical Split
';
34 % o.moreactions = {'go
', 'extract_logs
', 'extract_curves
'};
39 methods (Access=protected)
40 %> Allocates cell of logs (no_logs)X(no_blocks)X(no_reps) allocated with no_pieces slots
41 function o = allocate_logs(o)
42 if ~iscell(o.log_mold)
47 if ~iscell(o.block_mold)
48 bmold = {o.block_mold};
53 no_logs = numel(mold);
54 no_blocks = numel(o.blocks);
55 o.logs = cell(no_logs, no_blocks, o.no_reps);
59 o.logs{i, j, k} = mold{i}.allocate(numel(o.pieces));
60 o.logs{i, j, k}.title = ['From classifier
', bmold{j}.get_description()];
66 %> Allocates cell of blocks (1)X(no_blocks)
67 function o = allocate_blocks(o)
68 if ~iscell(o.block_mold)
69 mold = {o.block_mold};
73 no_blocks = numel(mold);
74 o.blocks = cell(1, no_blocks);
76 o.blocks{i} = mold{i}.boot();
84 o = o.boot_postpr(); % from reptt
87 s = RandStream.getDefaultStream; % Random stream used in random functions (default one).
88 save_State = s.State; % Saves state to restore later.
89 reset(s, o.randomseed); % Resets state to one made from o.randomseed
92 o.pieces = data_split_classes(o.data, o.hie_split);
94 for i = 1:np % Not sure about the future of aggr_hiesplit
95 o.pieces(i) = data_select_hierarchy(o.pieces(i), o.hie_classify);
98 o = o.allocate_blocks();
100 o = o.allocate_logs();
102 % Only needs to do it once
103 if ~isempty(o.postpr_test)
104 o.pvt_data_test = o.postpr_test.use(data_select_hierarchy(o.data_test, o.hie_classify));
106 o.pvt_data_test = data_select_hierarchy(o.data_test, o.hie_classify);
109 [nl, nb, nr] = size(o.logs);
111 ipro = progress2_open('REPTT_HIESPLIT
', [], 0, o.no_reps);
112 for i_rep = 1:o.no_reps
115 bl = o.blocks{i}.boot();
118 bl = bl.train(o.pieces(seq(k)));
120 est = bl.use(o.pvt_data_test);
122 if ~isempty(o.postpr_est)
123 est = o.postpr_est.use(est);
126 if isempty(est.classes)
127 irerror('Estimation post-processing did not assign classes!
');
130 pars = struct('est
', {est}, 'ds_test
', {o.pvt_data_test}, 'clssr', {bl});
132 o.logs{j, i, i_rep} = o.logs{j, i, i_rep}.record(pars);
136 ipro = progress2_change(ipro, [], [], i_rep);
138 progress2_close(ipro);
141 set(s, 'State
', save_State); % Restores default stream state so that random numbers can be generated as if nothing really happened here.
146 % Extract evolution curves from logs. Returns a cell matrix of @c irdata objects
147 function out = extract_curves(o)
148 [nl, nb, nr] = size(o.logs);
149 np = numel(o.pieces);
156 d.title = sprintf('LOG %s; BLOCK %s
', o.logs{i, j, 1}.get_description(), o.blocks{j}.get_description());
158 d.xname = 'Number of datasets added
';
162 % Yeah, get_rates() returns one curve
163 d.X(k, :) = o.logs{i, j, k}.get_rates();
Class-Hierarchical Training Data Split.