1 %> @brief One-
class-out SGS
3 %> Not published in GUI, currently.
8 %> =0. Whether to perform the one-
class-out split within each
class of @ref hie_split1 separately. Similar to the meaning of the
11 %> Hierarchical level(s) that will be used to separate the dataset if @ref flag_split1 is 1. Otherwise it is ignored
15 %> Class labels (because the dataset passed to @ref get_obsidxs() will have different class labels)
17 %> Classes. Must physically/semantically match the rows within the dataset that is passed to @ref get_obs_idxs(). Don't worry, @ref
20 %> Number of sub-sets per repetition. 2 is the classical train-test. 3 is the train-validate-test. From the second on, there is
21 %> going to be only one reserved class, then the rest goes into the first (training) (that's why it is called leave-one-class-out).
23 %> =10. Stands for the "K".
28 methods(Access=protected)
30 function idxs = get_repidxs(o)
33 map = cell2mat(map(:, 4));
34 % uniquemap = unique(map);
37 nreff = min(o.no_reps, nc);
39 irwarning(sprintf('Number of repetitions will be %d instead %d', nreff, o.no_reps));
43 irerror(sprintf('Number of subsets ("bites") too big. Maximum possible is %d', nreff));
46 idxsc = cell(nreff, o.no_bites);
50 for j = 1:o.no_bites-1
51 idx = cperm(mod(i+j-2, nc)+1);
55 idxsc{i, 1} = find(gone == 0);
58 classeseff = map(o.classes+1);
61 % First sees how many sub-problems we have
63 map1 = cell2mat(map1(:, 4));
67 map2 = cell2mat(map2(:, 4));
68 classeseff = map2(o.classes+1);
70 % Now sees the minimum effective number of repetitions
75 temp = numel(unique(map2(idxs1)));
76 nreff = min(nreff, temp);
77 minnc = min(minnc, temp);
81 irwarning(sprintf(
'Number of repetitions will be %d instead %d', nreff, o.no_reps));
85 irerror(sprintf(
'Number of subsets ("bites") too big. Maximum possible is %d', nreff));
88 idxsc_ = cell(nreff, o.no_bites, nc1);
91 map2now = map2(map1 == h-1);
92 unique2now = unique(map2now); % Unique
class numbers
93 nc2now = numel(unique2now);
94 cperm = randperm(nc2now);
96 gone = zeros(1, nc2now);
97 for j = 1:o.no_bites-1
98 idx0 = cperm(mod(i+j-2, nc2now)+1);
100 idxsc_{i, j+1, h} = unique2now(idx0);
102 idxsc_{i, 1, h} = unique2now(find(gone == 0));
106 % contatenates third dimension
107 idxsc = cell(nreff, o.no_bites);
110 temp = idxsc_(i, j, :);
111 idxsc{i, j} = cell2mat(temp(:));
115 classeseff = map2(o.classes+1);
122 idxs{i} = idxs_(i, :);
128 %> Parameter validation
129 function o = do_assert(o)
131 irerror('Grouping is not applicable!');
134 irerror('flag_perclass is not applicable!');
142 o.classtitle = 'One-class-out SGS';
Property flag_perclass
=0. Whether to perform on each class separately.
function data_select_hierarchy(in data, in hierarchy)
Base Sub-dataset Generation Specification (SGS) class.
function classmap2obsmap(in classmaps, in classes)
function classlabels2cell(in classlabels, in new_hierarchy)