IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
logrecorder.m
Go to the documentation of this file.
1 %> @brief Used to record a @ref ttlog based on test and estimation data
2 %>
3 %> The purpose is to provide objtool with a block that can be used to record a @ref ttlog based on
4 classdef logrecorder < block
5  properties
6  %> Test data, used as reference to compare the classes with those of the estimation dataset (input to use())
7  ds_test;
8  %> The classifier is used to get the class labels to make a default @ref estlog if the @ref logrecorder::ttlog is not passed
9  clssr;
10  %> @ref ttlog object
11  ttlog;
12  %> (Optional) Block to post-process the test data.
13  postpr_test;
14  %> Block to post-process the estimation issued by the classifier.
15  postpr_est;
16  end;
17 
18  methods
19  function o = logrecorder()
20  o.classtitle = 'Log recorder';
21  o.inputclass = 'estimato';
22  end;
23  end;
24 
25  methods(Access=protected)
26  %> Returns the object with its ttlog ready to have its get_rate() called.
27  function out = do_use(o, est)
28  if isempty(o.ttlog)
29  if isempty(o.clssr)
30  irerror('Cannot create default ttlog, needs classlabels from clssr!');
31  end;
32  irverbose('Logrecorder is creating default ttlog estlog_classxclass', 2);
33  z = estlog_classxclass();
34  z.estlabels = o.clssr.classlabels;
35  z.testlabels = o.ds_test.classlabels;
36  z = z.allocate(1);
37  o.ttlog = z;
38  end;
39 
40  if isempty(o.postpr_est)
41  if isempty(est.classes)
42  % Will create default postprocessors only if the classes of the estimation dataset are not assigned
43  o.postpr_est = def_postpr_est();
44  o.postpr_test = def_postpr_test(); % Overrides pospr_test because need a harmonic pair
45  end;
46  end;
47 
48  if ~isempty(o.postpr_est)
49  o.postpr_est = o.postpr_est.boot();
50  est = o.postpr_est.use(est);
51  end;
52 
53  if ~isempty(o.postpr_test)
54  o.postpr_test = o.postpr_test.boot();
55  ds_test = o.postpr_test.use(o.ds_test); %#ok<*PROP>
56  else
57  ds_test = o.ds_test;
58  end;
59 
60  pars.ds_test = ds_test;
61  pars.est = est;
62  pars.clssr = o.clssr;
63 
64  out = o.ttlog.record(pars);
65  end;
66  end;
67 end
function irverbose(in s, in level)
function compare(in o1, in o2)
function irerror(in s)
function objtool(in varargin)
Estimation logs base class.
Definition: estlog.m:4
Base Block class.
Definition: block.m:2
Records (test class)x([rejected, estimation class]) hits.
Classifiers base class.
Definition: clssr.m:6
Dataset representing estimation.
Definition: estimato.m:4
Analysis Session (AS) base class.
Definition: as.m:6
function def_postpr_test(in out)
Used to record a ttlog based on test and estimation data.
Definition: logrecorder.m:4
function def_postpr_est(in out)
Train-Test Log.
Definition: ttlog.m:4