1 %> @brief Feature Selection based on a
"grades" vector.
5 %> The features are selected in a two steps:
7 %> <h3>Stage 1 (optional)</h3>
8 %> In
this step, a @ref
peakdetector is used to select
"peak" features
for the next stage. If
this stage is skipped, all the features remain
11 %> Selects a number of features, either a fixed number of best-ranked features, or all features which ranked above a threshold (see
14 %> If FSG returns more than one grade vector (i.e., it uses an SGS that has 3 or more bites, or the @c data property has 3 or more elements),
15 %> the second vector will be used in
this stage. This corresponds to doing the 3rd stage optimization
using test sets that are independent from
16 %> the ones used to calculate the initial grades curve
18 %> This is univariate feature selection
25 %> =
'nf'. Possibilities:
26 %> @arg
'none': Skips the second stage
27 %> @arg
'nf': o.nf_select best ranked will be selected
28 %> @arg
'threshold': features with grade above o.threshold will be selected
33 %> Feature Subset Grader
object. Used
for optimization of number of features
36 %> =
'index'. How to sort the selected features.
37 %> @arg
'grade' descending order of grade
38 %> @arg
'index' ascending order ot index
44 o.classtitle = 'Grades-based';
49 methods(Access=protected)
51 function log = do_use(o, input)
55 log.fea_x = input.fea_x;
56 log.xname = input.xname;
57 log.xunit = input.xunit;
58 log.yname = input.yname;
59 log.yunit = input.yunit;
60 log.grades = input.grades;
61 log.threshold = o.threshold;
64 GRADE = 1; INDEX = 2; % defines for "howsorted"
66 %%%%% STAGE 1 (optional): peak detection
69 idxs = 1:numel(yidxs);
71 idxs = o.peakdetector.use(input.fea_x, input.grades);
72 yidxs = input.grades(idxs);
77 %%%%% STAGE 2: selection
81 if numel(yidxs) < o.nf_select
82 nf_effective = numel(yidxs);
83 irverbose(sprintf('INFO: Less than desired features will be selected (%d < %d)', numel(yidxs), o.nf_select), 1);
85 nf_effective = o.nf_select;
88 [dummy, sortedidxs] = sort(yidxs, 'descend');
89 newv = sortedidxs(1:nf_effective);
92 howsorted = GRADE; % Descending order of grades!
94 [foundvalues, foundidxs] = find(yidxs > o.threshold);
95 idxs = idxs(foundidxs);
96 yidxs = yidxs(foundidxs);
98 irerror(sprintf('Unknown univariate feature selection type ''%s''', o.type));
102 if howsorted == GRADE && strcmp(o.sortmode, 'index')
103 [idxs, dummy] = sort(idxs); %
#ok<NASGU>
104 elseif howsorted == INDEX && strcmp(o.sortmode,
'grade')
105 [dummy, idxtemp] = sort(yidxs,
'descend');
106 idxs = idxs(idxtemp);
function irverbose(in s, in level)
Generated by a as_grades object, carries a "grades" vector; usually.
Log generated by as_fsel_grades.
FSG - Feature Subset Grader.
Analysis Session that produces a log_as_fsel.
Feature Selection based on a "grades" vector.