IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
demo_feature_histogram_colors.m
Go to the documentation of this file.
1 %> @brief Shows different ways to paint the same Feature Histogram
2 %> @ingroup demo
3 %> @file
4 fig_assert();
5 % The dataset
7 ds = data_select_hierarchy(ds, 2); % Classes: N/T
8 
9 % The classifier
10 o = clssr_d();
11 o.type = 'linear';
12 clssr_d01 = o;
13 
14 % The FSG
15 o = fsg_clssr();
16 o.clssr = clssr_d01;
17 o.estlog = [];
18 o.postpr_est = [];
19 o.postpr_test = [];
20 o.sgs = [];
21 fsg_clssr01 = o;
22 
23 % The object that will do the feature selection
24 ofs = as_fsel_forward();
25 ofs.nf_select = 10; % <-------- Number of features to be selected
26 ofs.fsg = fsg_clssr01;
27 
28 % The SGS
29 osgs = sgs_randsub();
30 osgs.flag_group = 0;
31 osgs.flag_perclass = 0;
32 osgs.randomseed = 0;
33 osgs.no_reps = 50; % <-------- Number of repetitions for the histogram
34 
35 % The Feature Selection Repeater
36 orep = fselrepeater();
37 orep.sgs = osgs;
38 orep.as_fsel = ofs;
39 
40 %%
41 
42 log_rep = orep.use(ds); % This is the time-consuming line
43 
44 %%
45 
46 %> Stability and nf x grade
47 global SCALE;
48 SCALE = .8;
49 
50 ds_nfxgrade = log_rep.extract_dataset_nfxgrade();
51 ds_stab = log_rep.extract_dataset_stabilities();
52 
53 ov = vis_alldata();
54 
55 figure;
56 subplot(2, 1, 1);
57 ov.use(ds_nfxgrade);
58 legend off;
59 subplot(2, 1, 2);
60 ov.use(ds_stab);
61 legend off;
62 
63 maximize_window(gcf(), .8);
64 %%
65 SCALE = 1;
66 
67 ov = vis_stackedhists();
68 ov.data_hint = ds;
69 
70 ssp = subsetsprocessor();
71 
72 % Plots histogram in 3 different styles
73 figure;
74 for i = 1:3
75  if i == 1
76  %> All features are informative
77  ssp.nf4grades = [];
78  ssp.nf4gradesmode = 'fixed';
79  ov.colors = []; % Uses default color scheme from colors2map(), which accesses COLOR_STACKEDHISTS
80  elseif i == 2
81  %> 4 features are informative
82  ssp.nf4grades = 4;
83  ssp.nf4gradesmode = 'fixed';
84  ssp.stabilitythreshold = 0.05;
85  ov.colors = [];
86  elseif i == 3
87  %> Same as previous but with different color scheme
88  ssp.nf4grades = 4;
89  ssp.nf4gradesmode = 'fixed';
90  ssp.stabilitythreshold = 0.05;
91  ov.colors = {[.6, 0, 0], [1, 0, 0], [.7, .7, .7], [.9, .9, .9]};
92  end;
93  log_ssp = ssp.use(log_rep);
94 
95  subplot(3, 1, i);
96  ov.use(log_ssp); % .draw_stackedhists(ds, colors, []);
97  freezeColors();
98 end;
99 maximize_window(gcf(), 1.5);
100 save_as_png([], 'irr_histogram_colors');
function data_select_hierarchy(in data, in hierarchy)
Linear and Quadratic discriminant.
Definition: clssr_d.m:9
function maximize_window(in h, in aspectratio, in normalizedsize)
Visualization - All curves in dataset.
Definition: vis_alldata.m:2
function colors2map(in colors, in no_hists, in no_informative)
Visualization - Stacked histograms.
function save_as_png(in h, in fn, in dpi)
Forward Feature Selection.
Analysis Session - Feature Selection Repeater.
Definition: fselrepeater.m:4
Random Sub-sampling.
Definition: sgs_randsub.m:5
FSG that uses classifier to grade the subsets.
Definition: fsg_clssr.m:8
function load_data_she5trays()
Processor of a set of subsets of features.
Analysis Session (AS) base class.
Definition: as.m:6
function fig_assert()