IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
estlog_groupxclass.m
Go to the documentation of this file.
1 %> @brief Records (test group)x([rejected, estimation class]) hits
2 %>
3 %> Classification rates don't make sense in this case because there is no way to determine whether the classifications are correct.
4 %> Therefore, these methods are not inherited (they remain as in @ref estlog).
6  properties
7  %> All possible group codes. Assigned directly.
8  groupcodes;
9  %> All possible class labels in estimation datasets
10  estlabels = {};
11  end;
12 
13  methods
14  function o = estlog_groupxclass()
15  o.classtitle = 'Group X Class';
16  o.flag_params = 1;
17  end;
18  end;
19 
20  methods(Access=protected)
21  %> Returns the contents of the @c estlabels property.
22  function z = get_collabels(o)
23  z = o.estlabels;
24  end;
25 
26  %> Returns the contents of the @c testlabels property.
27  function z = get_rowlabels(o)
28  z = o.groupcodes;
29  end;
30 
31  function o = do_record(o, pars)
32  est = pars.est;
33  estclasses = renumber_classes(est.classes, est.classlabels, o.estlabels);
34  ds_test = pars.ds_test;
35  [ds_testgroupcodes, dummy, map] = unique(ds_test.groupcodes); % map contains information similar to crossvalind() output, i.e., repeated numbers mean same group.
36  for i = 1:max(map)
37  idxi = find(strcmp(ds_testgroupcodes{i}, o.groupcodes)); % Finds where current group sits in o.groupcodes
38  if isempty(idxi)
39  irerror(sprintf('Group "%s" not found in groupcodes list!', ds_testgroupcodes{i}));
40  end;
41 
42  rowidxs = map == i;
43  sel = estclasses(rowidxs);
44  if o.flag_support
45  supp = est.X(rowidxs, 1)';
46  end;
47 
48  for j = 1:numel(o.estlabels)
49  idxidxbool = sel == j-1;
50  o.hits(idxi, j+1, o.t) = o.hits(idxi, j+1, o.t)+sum(idxidxbool);
51  if o.flag_support
52  o.supports{idxi, j+1, o.t} = supp(idxidxbool);
53  end;
54  end;
55 
56  idxidxbool = sel == -1;
57  o.hits(idxi, 1, o.t) = sum(idxidxbool); % Rejection count.
58  if o.flag_support
59  o.supports{idxi, 1, o.t} = supp(idxidxbool); % Assumeed that est is the output of a decider block which produces a X with one feature only, which is the support.
60  end;
61  end;
62  end;
63  end;
64 end
function irerror(in s)
Estimation logs base class.
Definition: estlog.m:4
function renumber_classes(in classes_orig, in classlabels_orig, in classlabels_ref)
Analysis Session (AS) base class.
Definition: as.m:6
Records (test group)x([rejected, estimation class]) hits.