IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
blmisc_split_proportion.m
Go to the documentation of this file.
1 %> @brief Splits dataset in two according to proportion specified
2 %>
3 %> @sa uip_blmisc_split_proportion.m
5  properties
6  %> = 0.9.
7  proportion = 0.9;
8  %> =1: whether to keep spectra from the same group together or not.
9  flag_group = 1;
10  end;
11 
12  methods
13  function o = blmisc_split_proportion(o)
14  o.classtitle = 'Proportion';
15  end;
16  end;
17 
18  methods(Access=protected)
19  function datasets = do_use(o, data)
20  if ~o.flag_group || isempty(data.groupcodes)
21  p = randperm(data.no);
22  cut = floor(data.no*o.proportion);
23  datasets = data.split_map({p(1:cut), p(cut+1:end)});
24  else
25  p = randperm(data.no_groups);
26  cut = floor(data.no_groups*o.proportion);
27  v1 = data.get_obsidxs_from_groupidxs(p(1:cut));
28  v2 = data.get_obsidxs_from_groupidxs(p(cut+1:end));
29  datasets = data.split_map({v1, v2});
30  end;
31  end;
32  end;
33 end
34 
Splits dataset in two according to proportion specified.
Base class for blocks that split one dataset into many.
Definition: blmisc_split.m:2