IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
traintest.m
Go to the documentation of this file.
1 %> @file
2 %> @ingroup misc
3 %> @brief Runs a single train-test and returns the logged logs
4 %
5 %> @param logs Logs to record the outcome
6 %> @param blk Block expected to output an @re estimato dataset
7 %> @param ds_train Train dataset
8 %> @param ds_test Test dataset
9 %> @param postpr_test (optional) Post-processor block for ds_test
10 %> @param postpr_est (optional) Post-processor block for the estimation dataset, which is the output of <code>blk.use(ds_test)</code>
11 %> @return [logs, blk] [Recorded logs, trained block]
12 function [logs, blk] = traintest(logs, blk, ds_train, ds_test, postpr_test, postpr_est)
13 
14 if nargin < 6 || isempty(postpr_est)
15  postpr_est = decider();
16 end;
17 
18 if nargin < 5
19  postpr_test = [];
20 end;
21 
22 blk = blk.boot();
23 blk = blk.train(ds_train);
24 est = blk.use(ds_test);
25 
26 if ~isempty(postpr_est)
27  postpr_est = postpr_est.boot();
28  est = postpr_est.use(est);
29 end;
30 
31 
32 if ~isempty(postpr_test)
33  postpr_test = postpr_test.boot();
34  ds_test = postpr_test.use(ds_test);
35 end;
36 
37 pars = struct('est', {est}, 'ds_test', {ds_test}, 'clssr', {blk});
38 if iscell(logs)
39  for il = 1:numel(logs)
40  logs{il} = logs{il}.record(pars);
41  end;
42 else
43  logs = logs.record(pars);
44 end;
Block that resolves estimato posterior probabilities into classes.
Definition: decider.m:10
Base Block class.
Definition: block.m:2
function traintest(in logs, in blk, in ds_train, in ds_test, in postpr_test, in postpr_est)
Dataset representing estimation.
Definition: estimato.m:4