IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
as_fsel_lasso.m
Go to the documentation of this file.
1 %> @brief LASSO feature selection
3  properties
4  %> Number of features to be selected
5  nf_select;
6  end;
7 
8  methods
9  function o = as_fsel_lasso()
10  o.classtitle = 'LASSO';
11  o.flag_ui = 0;
12  end;
13  end;
14 
15  methods(Access=protected)
16  function log = do_use(o, data)
17  ds = data(1);
18  if ds.nc > 2
19  irerror('LASSO feature selection works with 2-class datasets only!');
20  end;
21 
22  Y = ds.classes*2-1;
23  L = abs(lasso(ds.X, Y, -o.nf_select, false));
24 
25  % Sorts in descending order of importance and trims
26  coeff = abs(L);
27  coeff = coeff(:)';
28  [vv, ii] = sort(coeff, 'descend');
29  if numel(ii) > o.nf_select
30  ii = ii(1:o.nf_select);
31  end;
32  grades = zeros(1, ds.nf);
33  grades(ii) = coeff(ii);
34 
35 
36 
37  log = log_as_fsel();
38  log.grades = grades;
39  log.fea_x = ds.fea_x;
40  log.xname = ds.xname;
41  log.xunit = ds.xunit;
42  log.yname = 'LASSO coefficient';
43  log.v = ii;
44  end;
45  end;
46 end
function irerror(in s)
Log generated by an as_fsel class.
Definition: log_as_fsel.m:2
LASSO feature selection.
Definition: as_fsel_lasso.m:2
Analysis Session that produces a log_as_fsel.
Definition: as_fsel.m:2