IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
fsel.m
Go to the documentation of this file.
1 %> @brief Feature Selection (FSel) class
2 %>
3 %> @sa get_feaidxs.m
4 classdef fsel < fext
5  properties
6  %> =[]. See get_feaidxs.m
7  v = [];
8  %> ='i'. See get_feaidxs.m
9  v_type = 'i';
10  %> =0. See get_feaidxs.m
11  flag_complement = 0;
12  end;
13 
14 
15  % These are optional properties
16  properties
17  %> [1][nf] vector containing feature evaluation grades.
18  grades = [];
19  %> x-axis values corresponding to the @c grades y-axis values
20  fea_x;
21  %> Input feature names, empty or having as many elements as fea_x
22  fea_names = [];
23  %> Name corresponding to fea_x
24  xname = '';
25  xunit = '';
26  %> Name of y-axis (grades)
27  yname = 'Hit';
28  %> Unit of y-axis (grades)
29  yunit = '';
30  end;
31 
32  methods
33  function o = fsel()
34  o.classtitle = 'Feature Selection';
35  o.short = 'FSel';
36  end;
37 
38  %> Copies properties from object with the following properties:
39  %> <code>
40  %> obj.
41  function o = copy_axes_from(o, obj)
42  o.fea_names = obj.fea_names;
43  o.fea_x = obj.fea_x;
44  o.xname = obj.xname;
45  o.yname = obj.yname;
46  o.xunit = obj.xunit;
47  o.yunit = obj.yunit;
48  end;
49 
50  %> Draws selected features
51  %>
52  %> Only works if @c type is 'i' and flag_complement is false, otherwise gives an error.
53  function o = draw(o, data_hint)
54  if ~exist('data_hint', 'var')
55  data_hint = [];
56  end;
57 
58  if strcmp(o.v_type, 'i') && ~o.flag_complement
59  if isempty(o.grades)
60  % Best I can do if these optional variables are empty
61  nn = max(o.v);
62  grades_ = zeros(1, nn);
63  fea_x_ = 1:nn;
64  else
65  grades_ = o.grades;
66  fea_x_ = o.fea_x;
67  end;
68 
69 
70  if ~isempty(data_hint)
71  xhint = data_hint.fea_x;
72  yhint = mean(data_hint.X);
73  else
74  xhint = [];
75  yhint = [];
76  end;
77 
78  draw_loadings(fea_x_, grades_, xhint, yhint, [], 0, [], 0, 0, 0, 1); % 1 is the flag_histogram
79 
80  draw_peaks(fea_x_, o.grades_, o.v, 0);
81 
82  format_xaxis(o);
83  ylabel(gca, o.yname);
84  make_box();
85  else
86  irerror('v_type must be ''i'' and flag_complement must be off@!');
87  end;
88  end;
89  end;
90 
91  methods(Access=protected)
92  % This functionality is likely to be kept by descendants, which will probably concentrate on training
93  function data = do_use(o, data)
94  if ~(strcmp(o.v_type, 'i') && ~o.flag_complement)
95  idxs = get_feaidxs(data.fea_x, o.v, o.v_type, o.flag_complement);
96  data = data.select_features(idxs);
97  else
98  data = data.select_features(o.v);
99  end;
100  end;
101  end;
102 end
function draw_peaks(in x, in y, in indexes, in flag_text, in color, in marker, in markersize)
Feature Selection (FSel) class.
Definition: fsel.m:4
function make_box()
function irerror(in s)
Feature Extraction (Fext) base class.
Definition: fext.m:4
function draw_loadings(in x, in L, in x_hint, in hint, in legends, in flag_abs, in peakd, in flag_trace_minalt, in flag_draw_peaks, in flag_print_peaks, in flag_histogram, in flag_envelope, in colors)
Analysis Session (AS) base class.
Definition: as.m:6
function format_xaxis(in par)
function get_feaidxs(in x, in v, in v_type, in flag_complement)