IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
demo_forward.m
Go to the documentation of this file.
1 %> @brief Forward feature selection demo
2 %> @ingroup demo
3 %> @file
4 
6 ds = data_select_hierarchy(ds, 2); % Classes will be N/T
7 
8 
9 % The classifier
10 o = clssr_d();
11 o.type = 'quadratic';
12 clssr_d01 = o;
13 
14 % The SGS
15 o = sgs_crossval();
16 o.flag_group = 1;
17 o.flag_perclass = 0;
18 o.randomseed = 0;
19 o.flag_loo = 0;
20 o.no_reps = 10;
21 sgs_crossval01 = o;
22 
23 % The FSG
24 o = fsg_clssr();
25 o.clssr = clssr_d01;
26 o.estlog = [];
27 o.postpr_est = [];
28 o.postpr_test = [];
29 o.sgs = sgs_crossval01;
30 fsg_clssr01 = o;
31 
32 % The object that will do the feature selection
33 o = as_fsel_forward();
34 o.nf_select = 9; % Number of features to be selected
35 o.fsg = fsg_clssr01;
36 as_fsel_forward01 = o;
37 
38 log = as_fsel_forward01.use(ds);
39 
40 
41 % ^^^^^^ Calculations finished ^^^^^^
42 
43 %%
44 % Extracts feature selection block...
45 out = log.extract_fsel();
46 fsel_forward01 = out;
47 
48 % Applies to dataset
49 [fsel_forward01, out] = fsel_forward01.use(ds);
50 ds_fsel01 = out;
51 disp([10, '-<= Features selected =>-']);
52 fprintf(' -> %5.1f cm^-1 <-\n', ds_fsel01.fea_x);
53 disp(' ');
54 
55 
56 % Visualizations
57 
58 % Classification rate progression ((nf) x (rate) curve)
59 out = log.extract_dataset();
60 irdata_forward01 = out;
61 o = vis_alldata();
62 figure;
63 o.use(irdata_forward01);
64 legend off;
65 title('Classification rate progression');
66 
67 % Selected features
68 o = vis_log_as_fsel();
69 o.data_hint = ds;
70 o.flag_mark = 1;
71 figure;
72 o.use(log);
73 title('Features selected');
74 maximize_window([], 7);
75 
function data_select_hierarchy(in data, in hierarchy)
Visual representation of selected features.
Linear and Quadratic discriminant.
Definition: clssr_d.m:9
K-Fold Cross-Validation.
Definition: sgs_crossval.m:6
function maximize_window(in h, in aspectratio, in normalizedsize)
Visualization - All curves in dataset.
Definition: vis_alldata.m:2
function use(in o, in data)
Applies block to data.
Base Block class.
Definition: block.m:2
Forward Feature Selection.
FSG that uses classifier to grade the subsets.
Definition: fsg_clssr.m:8
function load_data_she5trays()