1 %> @brief FSG - Feature Subset Grader
3 %> FSG is always equipped with cross-validation capability. Descendant classes must always implement the
4 %> cross-validation and no cross-validation cases. Whether there is cross-validation is determining by the @ref
sgs
5 %>
property being set or not.
8 %> =@min. Function pointer to aggregate a vector of pairwise grades. As seen, the
default behaviour is taking the least grade obtained among all pairwise gradings.
9 f_aggr = @(z) min(z, [], 1);
10 %> SGS
object. If set,
12 %> Some trainable
block for convenience. This can be used to pass a
pre_std so that it doesn
't have to be part of the classifier itself.
13 %> This block typically is trainable and treats the features independently. Having it as part of the classifier would result in unnecessary
14 %> repetition of the same operation.
18 properties(SetAccess=protected)
24 %> Assigned by @ref prepare(). This is a cell vector of Cell of matrices of @c irdata datasets
30 properties(Access=protected)
32 %> The algorithm is clever enough to go non-pairwise mode if flag_pairwise is TRUE but the dataset has less than three classes
33 pvt_flag_pairwise = 0;
34 %> Assigned by @c set_data()
36 %> If not pairwise (see @ref flag_pairwise), @c data will be assigned to @ref datasets.
38 %> If pairwise, @ref datasets will be a matrix of dimensions <code>(number of pairs)x(numel(data))</code>
40 %> Why one would pass a more-than-one-element dataset through @c data depends on the behaviour of a particular
41 %> @ref fsg descendant. For instance a two-element vector could be a train-test pair.
48 %> @return A string for an y-axis label
49 function s = get_yname(o)
53 %> @return A string for a y-axis unit
54 function s = get_yunit(o)
59 methods(Access=protected)
60 %> Abstract. Must return a column vector with as elements as number of datasets
61 function z = do_calculate_pairgrades(o, idxs) %#ok<INUSD>
77 %> Assigns the @ref datasets property.
81 %> @param data Vector of datasets.
82 function o = set.data(o, data)
87 o.pvt_flag_pairwise = o.flag_pairwise && data.nc > 2;
88 if ~o.pvt_flag_pairwise
91 % pairwise is slow, who cares
93 irwarning('One-versus-one FSG needs all datasets with exactly same classlabels
');
95 bl = blmisc_split_ovo();
96 % pairwise split is applied dataset-wise. Each dataset originates a column in o.datasets
97 o.datasets = irdata.empty;
98 for i = 1:numel(data);
99 pieces = bl.use(data(i));
100 o.datasets(:, i) = pieces';
102 %
for i = 1:length(pieces)
103 % o.datasets{i} = pieces(i);
110 o.classtitle = 'Feature Subset Grader';
111 o.color = [170, 193, 181]/255;
114 %> Assigns the @ref subddd property
116 o.flag_sgs = ~isempty(o.sgs);
118 for i = 1:size(o.datasets, 1)
119 data = o.datasets(i, 1); % See that for cross-validaton only the first column of o.datasets is used.
120 obsidxs = o.sgs.get_obsidxs(data);
121 o.subddd{i} = data.split_map(obsidxs, [], o.fext);
128 %> May
return one grade or a vector thereof
130 %> @param idxs May be either: a cell of feature subsets; or a vector of feature indexes. Developers please note
131 %> that it is the end
class responsibility to give proper treatment to this. The option is left open for speed,
132 %>
as there is no point in
using a cell in univariate cases.
133 function grades = calculate_grades(o, idxs)
137 if o.flag_univariate && length(idxs{1}) > 1
138 irerror(
'Univariate Feature-Subset Grader was requested to grade multivariate data!');
141 grades_ = o.do_calculate_pairgrades(idxs);
143 for k = 1:size(grades_, 3)
144 grades(:, :, k) = o.f_aggr(grades_(:, :, k));
Standardization (trained)
Base Sub-dataset Generation Specification (SGS) class.
FSG - Feature Subset Grader.
Analysis Session (AS) base class.