1 %> @brief Pairwise classifier
3 %> Creates one classifier per 2-
class combination of the training dataset. For example, if the dataset has 4 classes, 6
4 %> classifiers will be created, each one trained respectively on a 2-
class sub-dataset: classes [0, 1]; [0, 2]; [0, 3]; [1, 2]; [1, 3]; [2, 3]
6 %> @sa uip_aggr_pairs.m
9 % must contain a block object that will be replicated as needed
14 function o = aggr_pairs()
15 o.classtitle = 'One-versus-one';
21 methods(Access=protected)
22 function o = do_boot(o)
26 % Adds classifiers when new classes are presented
27 function o = do_train(o, data)
29 nb = length(o.blocks);
31 ntotal = nc*(nc-1)/2; % Total number of models that will be created
32 pieces = data_split_classes(data); % Por enquanto assim, mas dava pra tentar um split unico
37 % Finds classifier that is assigned to classes corresponding to (i1, i2)
38 cl_data = {pieces(i1).classlabels{1}, pieces(i2).classlabels{1}}; % I am not relying on the pieces being in the same order of data.classlabelslabels
41 if sum(strcmp(cl_data, o.blocks(ib).classlabels)) == 2
47 % Pair of classes (i1, i2) has not been seen so far, so creates new classifier
48 o.blocks(nb+1).block = o.block_mold.boot();
49 o.blocks(nb+1).classlabels = cl_data;
50 o.classlabels = unique([o.classlabels, cl_data]);
56 % irverbose(sprintf('agg_pairs::train(): training model %d/%d...\n', ifound, ntotal), 0);
57 o.blocks(ifound).block = o.blocks(ifound).block.train(data_merge_rows(pieces([i1, i2])));
58 o.time_train = o.time_train+o.blocks(ifound).block.time_train;