IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
reptt_bag Class Reference

Detailed Description

REPTT for bagging classifiers.

Implements a nested loop: external is just a repetition ("bagging repetitions"); internal is a cross-validation loop.

The particularity of a bagging train-test session is that each iteration of the bagging loop will do exactly the same thing: train the classifiers with exactly the same data at each iteration

Usage

Calling go() will build the blocks and logs properties.

The blocks property will be a [no_datasets]x[no_blocks] matrix, where no_datasets is the number of sub-samples generated by the SGS; no_blocks is the number of elements of the block_mold property. It is expected that the blocks are classifiers (clssr).

The reptt_bag::sgs property defines a number of sub-datasets. To each row of the blocks property corresponds one dataset, i.e., at every "bagging repetition" (bag_rep()), all the classifiers in the row will be re-trained on their corresponding dataset. This is why this class is designed for bagging classifiers (aggr_bag). Internally, such classifier will draw sub-datasets (sub-sub-datasets if you consider that each training dataset is already a sub-dataset to train component classifiers.

The logs property is a 3D matrix, [no_logs]x[no_blocks]x[no_bagreps]. Inspecting the logs individually has little practical meaning.

The "results" are obtained throught extract_curves() which generates one dataset per log in the log_mold property. The dataset x-axis correspond to "bagging repetitions" and the values are classification rates. Only one row will be generated per classifier in the block_mold property. It is expected that the classification rate will rise with the bagging repetitions.

Another "results" options is using extract_as_dsperc_x_rate()

Todo:
temporarily deactivated.
See also
uip_reptt_bag.m, demo_reptt_bag.m

Definition at line 35 of file reptt_bag.m.

+ Inheritance diagram for reptt_bag:
+ Collaboration diagram for reptt_bag:

Public Member Functions

function reptt_bag ()
 
function boot (in o, in data)
 
function assert_booted (in o)
 
function go (in o)
 This function just calls do_bagrep() no_bagreps times. More...
 
function do_bagrep (in o)
 
function extract_curves (in o)
 
function get_grades (in o, in params)
 Abstract. Method to get the per-feature grades. BMTool stuff. More...
 
function get_gradeslegend (in o, in params)
 Abstract. Method to get block title based on passed parameters. BMTool stuff. More...
 
function use (in o, in data)
 Applies block to data. More...
 
function train (in o, in data, in varargin)
 Trains block. More...
 
function boot (in o)
 Configures the structure to deal with new type of data. More...
 
function get_description (in o, in flag_short)
 
function setbatch (in o, in params)
 Sets several properties of an object at once. More...
 
function get_methodname (in o, in flag_short)
 
function get_report (in o)
 Object reports are plain text. HTML would be cool but c'mon, we don't need that sophistication. More...
 
function get_html (in o, in flag_stylesheet)
 
function get_params (in o, in data)
 Calls Parameters GUI. More...
 
function extract_log (in o)
 
function get_ancestry (in o, in flag_title)
 

Public Attributes

Property sgs
 
Property no_bagreps
 Number of bagging repetitions. More...
 
Property block_mold
 Cell array. Blocks to be trained-tested. More...
 
Property log_mold
 Cell array. Molds for the recording. More...
 
Property postpr_test
 (Optional) Block to post-process the test data. For example, a grag_classes_first. More...
 
Property postpr_est
 
Property logs
 Mounted at "runtime". More...
 
Property blocks
 Mounted at "runtime". More...
 
Property title
 
Property color
 

Protected Member Functions

function allocate_blocks (in o)
 
function allocate_logs (in o)
 
function boot_postpr (in o)
 
function do_train (in o, in data)
 
function do_use (in o, in data)
 
function do_boot (in o)
 Boots the block. More...
 
function do_get_report (in o)
 Default report. More...
 
function do_get_html (in o)
 Abstract. HTML inner body. More...
 

Protected Attributes

Property obsidxs
 
Property datasets
 
Property i_bagrep
 
Property no_datasets
 Deserves a property because in this way, dataset may be cleaned, and this property still remains. More...
 
Property inputclass
 
Property flag_bootable
 =0. (High-Level setting and internal function) Whether or not the block is bootable. More...
 
Property flag_trainable
 =0. (High-Level + internal function). Whether or not the block can be trained, or completely non-data-based. More...
 
Property flag_incrtrain
 
Property flag_fixednf
 =1. (internal function) If true, dataset number of features will be checked upon training and using. Ignored if o.flag_trainable is 0. More...
 
Property flag_fixedno
 =0. (internal function) If true, dataset number of observations will be checked upon training and using. Ignored if o.flag_trainable is 0. More...
 
Property flag_multiin
 =0. (High-Level setting (gencode)) Whether block allows/expects multiple objects as input. More...
 
Property flag_out
 =1. (High-Level setting (gencode)) Whether the block generates any output at all (counterexample: vis blocks) More...
 
Property flag_train_inliers_only
 
Property flag_train_require_inliers
 
Property nf
 =-1. Number of features. Cleared at boot(), assigned or reinforced at train(). More...
 
Property no
 =-1. Number of observations. More...
 
Property flag_trained
 =0. Set to 1 by train() if training is successful; set back to 0 after booting. More...
 
Property flag_booted
 =0. Set to 1 by boot() after booting the block More...
 
Property time_train
 Trainings time. More...
 
Property time_use
 Use time. More...
 
Property classtitle
 Class Title. Should have a descriptive name, as short as possible. More...
 
Property short
 Short for the method name. More...
 
Property flag_params
 
Property flag_ui
 (GUI setting) Whether to "publish" in blockmenu and datatool. Note that a class can be "published" without a GUI (set flag_params=0 in this case, at the class constructor). More...
 
Property moreactions
 (GUI setting) String cell containing names of methods that may be called from the GUIs More...
 

Constructor & Destructor Documentation

function reptt_bag::reptt_bag ( )

Member Function Documentation

function reptt_bag::allocate_blocks ( in  o)
protected

Allocates cell of blocks (no_datasets)X(no_blocks), where no_datasets is the number of sub-samples generated by the SGS, and no_blocks is the number of elements of the block_mold property.

This function must be called BEFORE allocate_logs()

function reptt_bag::allocate_logs ( in  o)
protected

Allocates cell of logs (no_logs)X(no_blocks)X(o.no_bagreps), each one allocated with no_datasets slots, where no_logs is the number of elements in the log_mold property, and no_blocks is the number of elements in the block_mold property.

This method must be called AFTER allocate_blocks()

function reptt_bag::assert_booted ( in  o)
function reptt_bag::boot ( in  o,
in  data 
)
function block::boot ( in  o)
inherited

Configures the structure to deal with new type of data.

Booting accounts for clearing any recordings; model structure; stored data etc from the object so that it can be re-used anew.

function reptt::boot_postpr ( in  o)
protectedinherited

Checks validity of post_processors and boots them.

Please note that this will pass if either or both are empty.

These is a tool to be used by descendant classes, as required.

function reptt_bag::do_bagrep ( in  o)
function block::do_boot ( in  o)
protectedinherited

Boots the block.

Abstract. Booting accounts for clearing any recordings; model structure; stored data etc from the object so that it can be re-used anew.

function irobj::do_get_html ( in  o)
protectedinherited

Abstract. HTML inner body.

function irobj::do_get_report ( in  o)
protectedinherited

Default report.

function block::do_train ( in  o,
in  data 
)
protectedinherited
function block::do_use ( in  o,
in  data 
)
protectedinherited
function reptt_bag::extract_curves ( in  o)

Generates as many datasets as there are elements in the log_mold property.

Each dataset will have one curve per element in the block_mold property X per sub-dateset. Each element in block_mold gives a different class. Each element in log_mold gives a different dataset.

function irobj::extract_log ( in  o)
inherited
Parameters
o
Returns
[o, log]
function irobj::get_ancestry ( in  o,
in  flag_title 
)
inherited
Parameters
o
flag_title=1
function irobj::get_description ( in  o,
in  flag_short 
)
inherited

Returns description string

Precedence according with flag_short:

  • 0: title > short > classtitle
  • 1: short > title > classtitle
Parameters
flag_short=0I am sealing this to make sure that no class will try to improvise on this function.
function block::get_grades ( in  o,
in  params 
)
inherited

Abstract. Method to get the per-feature grades. BMTool stuff.

function block::get_gradeslegend ( in  o,
in  params 
)
inherited

Abstract. Method to get block title based on passed parameters. BMTool stuff.

function irobj::get_html ( in  o,
in  flag_stylesheet 
)
inherited
Parameters
flag_stylesheet=1Whether to include the stylesheet in the HTML
function irobj::get_methodname ( in  o,
in  flag_short 
)
inherited

This is used only to compose sequence string e.g. xxx->yyy->zzz

Parameters
flag_short=0
function irobj::get_params ( in  o,
in  data 
)
inherited

Calls Parameters GUI.

If flag_params, tries uip_<class>.m. If fails, tries uip_<ancestor>.m and so on

function irobj::get_report ( in  o)
inherited

Object reports are plain text. HTML would be cool but c'mon, we don't need that sophistication.

function reptt_bag::go ( in  o)

This function just calls do_bagrep() no_bagreps times.

function irobj::setbatch ( in  o,
in  params 
)
inherited

Sets several properties of an object at once.

Parameters
o
paramsCell followint the pattern
{'property1', value1, 'property2', value2, ...} 
function block::train ( in  o,
in  data,
in  varargin 
)
inherited

Trains block.

function block::use ( in  o,
in  data 
)
inherited

Applies block to data.

Member Data Documentation

Property reptt::block_mold
inherited

Cell array. Blocks to be trained-tested.

Definition at line 14 of file reptt.m.

Property reptt::blocks
inherited

Mounted at "runtime".

Definition at line 35 of file reptt.m.

Property irobj::classtitle
protectedinherited

Class Title. Should have a descriptive name, as short as possible.

Definition at line 50 of file irobj.m.

Property irobj::color
inherited

=[0, .8, 0]. multipurpose feature, routines may use it for different things. Major use is to change the background of objtool and blockmenu. See also classes_html.m

Definition at line 42 of file irobj.m.

Property reptt_bag::datasets
protected

Definition at line 50 of file reptt_bag.m.

Property block::flag_bootable
protectedinherited

=0. (High-Level setting and internal function) Whether or not the block is bootable.

Definition at line 14 of file block.m.

Property block::flag_booted
protectedinherited

=0. Set to 1 by boot() after booting the block

Definition at line 69 of file block.m.

Property block::flag_fixednf
protectedinherited

=1. (internal function) If true, dataset number of features will be checked upon training and using. Ignored if o.flag_trainable is 0.

Definition at line 28 of file block.m.

Property block::flag_fixedno
protectedinherited

=0. (internal function) If true, dataset number of observations will be checked upon training and using. Ignored if o.flag_trainable is 0.

Definition at line 31 of file block.m.

Property block::flag_incrtrain
protectedinherited

=0. (internal function). Whether or not the block accepts incremental training. The meaning is:

  • If YES, it means that the block can adapt/evolve everytime its train() method is called
  • If NO, the block can be trained only once, and calling its train() method many times can lead to unpredictable results

Definition at line 23 of file block.m.

Property block::flag_multiin
protectedinherited

=0. (High-Level setting (gencode)) Whether block allows/expects multiple objects as input.

Definition at line 35 of file block.m.

Property block::flag_out
protectedinherited

=1. (High-Level setting (gencode)) Whether the block generates any output at all (counterexample: vis blocks)

Definition at line 38 of file block.m.

Property irobj::flag_params
protectedinherited

=1. (GUI setting) Whether to call a GUI when the block is selected in blockmenu.m . If true, a routine called "uip_"<class name> will be called.

Definition at line 57 of file irobj.m.

Property block::flag_train_inliers_only
protectedinherited

If true, train() will pass on to do_train() a dataset with inliers only. If this flag is true, flag_train_require_inliers will be ignored, because flag_train_inliers_only being true is one way to solve the "inliers requirement".

Definition at line 46 of file block.m.

Property block::flag_train_require_inliers
protectedinherited

=1. If true, train() will give an error if the dataset has outliers. This is true by default, because the developer should be aware of outliers being inputted into a training algorithm.

Definition at line 51 of file block.m.

Property block::flag_trainable
protectedinherited

=0. (High-Level + internal function). Whether or not the block can be trained, or completely non-data-based.

Definition at line 17 of file block.m.

Property block::flag_trained
protectedinherited

=0. Set to 1 by train() if training is successful; set back to 0 after booting.

Definition at line 66 of file block.m.

Property irobj::flag_ui
protectedinherited

(GUI setting) Whether to "publish" in blockmenu and datatool. Note that a class can be "published" without a GUI (set flag_params=0 in this case, at the class constructor).

Definition at line 60 of file irobj.m.

Property reptt_bag::i_bagrep
protected

Definition at line 52 of file reptt_bag.m.

Property block::inputclass
protectedinherited

='irdata'. (High-Level setting) Class or classes (can be string or cell of strings) that the block can deal with. Allows for objtool and datatool to know (when appropriate) which blocks are applicable to the selected object(s).

Definition at line 11 of file block.m.

Property reptt::log_mold
inherited

Cell array. Molds for the recording.

Definition at line 17 of file reptt.m.

Property reptt::logs
inherited

Mounted at "runtime".

Definition at line 32 of file reptt.m.

Property irobj::moreactions
protectedinherited

(GUI setting) String cell containing names of methods that may be called from the GUIs

Definition at line 63 of file irobj.m.

Property block::nf
protectedinherited

=-1. Number of features. Cleared at boot(), assigned or reinforced at train().

Definition at line 60 of file block.m.

Property block::no
protectedinherited

=-1. Number of observations.

Definition at line 63 of file block.m.

Property reptt_bag::no_bagreps

Number of bagging repetitions.

Definition at line 43 of file reptt_bag.m.

Property reptt_bag::no_datasets
protected

Deserves a property because in this way, dataset may be cleaned, and this property still remains.

Definition at line 55 of file reptt_bag.m.

Property reptt_bag::obsidxs
protected

Definition at line 48 of file reptt_bag.m.

Property reptt::postpr_est
inherited

Block to post-process the estimation issued by the classifier. Examples:

Definition at line 25 of file reptt.m.

Property reptt::postpr_test
inherited

(Optional) Block to post-process the test data. For example, a grag_classes_first.

Definition at line 20 of file reptt.m.

Property reptt_bag::sgs

Definition at line 40 of file reptt_bag.m.

Property irobj::short
protectedinherited

Short for the method name.

Definition at line 53 of file irobj.m.

Property block::time_train
protectedinherited

Trainings time.

Definition at line 73 of file block.m.

Property block::time_use
protectedinherited

Use time.

Definition at line 76 of file block.m.

Property irobj::title
inherited

Definition at line 38 of file irobj.m.


The documentation for this class was generated from the following file: