1 %> @brief K-Fold Cross-Validation
3 %> Cross-validation only produces two bites: usually corresponding to training and test data
5 %> @sa uip_sgs_crossval.m
8 %> =10. Stands
for the
"K". Ignored
if flag_loo is TRUE.
10 %> =0. Whether leave-one-out or K-fold.
12 %> =0. Whether to automatically reduce the number of folds
if no_reps is
13 %> too big
for the dataset.
17 properties(Access=
private)
21 methods(Access=protected)
23 function o = do_assert(o)
24 if o.flag_loo && o.flag_perclass
25 irerror('Cannot perform leave-one-out cross-validation per class!');
30 function o = do_setup(o)
32 o.pvt_no_reps = o.no_unitss;
34 if any(o.no_reps > o.no_unitss)
35 min_value = min(o.no_unitss);
37 o.pvt_no_reps = min_value;
38 irverbose(sprintf('INFO: Cross-validation k reduced from %d to %d', o.no_reps, min_value));
40 irerror(sprintf('Cross-validation k=%d is bigger than the number of units=%d in dataset!', o.no_reps, min(o.no_unitss)));
43 o.pvt_no_reps = o.no_reps;
49 function idxs = get_repidxs(o)
50 idxs = cell(1, o.pvt_no_reps);
52 idxs_cross = crossvalind('kfold', o.no_unitss(j), o.pvt_no_reps);
53 idxs_seq = 1:o.no_unitss(j);
54 for i = 1:o.pvt_no_reps
56 idxs{i} = cell(o.no_pieces, 2);
58 idxs{i}(j, [1, 2]) = {idxs_seq(idxs_cross ~= i), idxs_seq(idxs_cross == i)};
66 o.classtitle = 'K-Fold Cross-Validation';
function irverbose(in s, in level)
Base Sub-dataset Generation Specification (SGS) class.