Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::StackedLearner Class Reference

#include <StackedLearner.h>

Inheritance diagram for PLearn::StackedLearner:

Inheritance graph
[legend]
Collaboration diagram for PLearn::StackedLearner:

Collaboration graph
[legend]
List of all members.

Public Types

typedef PLearner inherited

Public Member Functions

 StackedLearner ()
void setTrainStatsCollector (PP< VecStatsCollector > statscol)
 Sets the statistics collector whose update() method will be called during training.

virtual void build ()
 simply calls inherited::build() then build_()

virtual void makeDeepCopyFromShallowCopy (map< const void *, void * > &copies)
 Transforms a shallow copy into a deep copy.

 PLEARN_DECLARE_OBJECT (StackedLearner)
virtual int outputsize () const
 returns the size of this learner's output, (which typically may depend on its inputsize(), targetsize() and set options)

virtual void forget ()
 (Re-)initializes the PLearner in its fresh state (that state may depend on the 'seed' option) And sets 'stage' back to 0 (this is the stage of a fresh learner!)

virtual void train ()
 The role of the train method is to bring the learner up to stage==nstages, updating the train_stats collector with training costs measured on-line in the process.

virtual void computeOutput (const Vec &input, Vec &output) const
 Computes the output from the input.

virtual void computeCostsFromOutputs (const Vec &input, const Vec &output, const Vec &target, Vec &costs) const
 Computes the costs from already computed output.

virtual TVec< stringgetTestCostNames () const
 Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method).

virtual TVec< stringgetTrainCostNames () const
 Returns the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats.

virtual void setTrainingSet (VMat training_set, bool call_forget=true)
 Declares the train_set Then calls build() and forget() if necessary.


Public Attributes

TVec< PP< PLearner > > base_learners
 A set of 1st level base learners that are independently trained (here or elsewhere) and whose outputs will serve as inputs to the combiner.

PP< PLearnercombiner
 A learner that is trained (possibly on a data set different from the one used to train the base_learners) using the outputs of the base_learners as inputs.

PP< Splittersplitter
 This can be and which data subset(s) goes to training the combiner.

PP< Splitterbase_train_splitter
 This can be used to split the training set into different training sets for each base learner.

bool train_base_learners
 whether to train the base learners in the method train (otherwise they should be initialized at construction / setOption time)

bool normalize_base_learners_output
 If set to 1, the output of the base learners on the combiner training set will be normalized (zero mean, unit variance).

bool precompute_base_learners_output
 If set to 1, the output of the base learners on the combiner training set will be precomputed in memory before training the combiner.

bool put_raw_input
 optionally put the raw input as additional input of the combiner

bool put_costs
 optionally put the costs of all the learners as additional inputs of the combiner (NB: this option actually isn't implemented yet)


Static Protected Member Functions

void declareOptions (OptionList &ol)
 Declares this class' options.


Protected Attributes

Mat base_learners_outputs

Private Member Functions

void build_ ()
 This does the actual building.


Member Typedef Documentation

typedef PLearner PLearn::StackedLearner::inherited
 

Reimplemented from PLearn::PLearner.

Definition at line 67 of file StackedLearner.h.


Constructor & Destructor Documentation

PLearn::StackedLearner::StackedLearner  ) 
 

Definition at line 51 of file StackedLearner.cc.


Member Function Documentation

void PLearn::StackedLearner::build  )  [virtual]
 

simply calls inherited::build() then build_()

Reimplemented from PLearn::PLearner.

Definition at line 159 of file StackedLearner.cc.

References build_().

void PLearn::StackedLearner::build_  )  [private]
 

This does the actual building.

Reimplemented from PLearn::PLearner.

Definition at line 132 of file StackedLearner.cc.

References base_learners, base_learners_outputs, combiner, PLearn::TVec< PP< PLearner > >::length(), PLERROR, PLearn::TMat< T >::resize(), and splitter.

Referenced by build().

void PLearn::StackedLearner::computeCostsFromOutputs const Vec input,
const Vec output,
const Vec target,
Vec costs
const [virtual]
 

Computes the costs from already computed output.

Implements PLearn::PLearner.

Definition at line 293 of file StackedLearner.cc.

References base_learners, base_learners_outputs, combiner, and PLearn::TMat< T >::toVec().

void PLearn::StackedLearner::computeOutput const Vec input,
Vec output
const [virtual]
 

Computes the output from the input.

Implements PLearn::PLearner.

Definition at line 278 of file StackedLearner.cc.

References base_learners, base_learners_outputs, PLearn::columnMean(), combiner, PLearn::TVec< PP< PLearner > >::length(), PLERROR, PLearn::TMat< T >::toVec(), and PLearn::Vec.

void PLearn::StackedLearner::declareOptions OptionList ol  )  [static, protected]
 

Declares this class' options.

Reimplemented from PLearn::PLearner.

Definition at line 75 of file StackedLearner.cc.

References PLearn::declareOption(), and PLearn::OptionList.

void PLearn::StackedLearner::forget  )  [virtual]
 

(Re-)initializes the PLearner in its fresh state (that state may depend on the 'seed' option) And sets 'stage' back to 0 (this is the stage of a fresh learner!)

Implements PLearn::PLearner.

Definition at line 190 of file StackedLearner.cc.

References base_learners, combiner, PLearn::TVec< PP< PLearner > >::length(), and train_base_learners.

TVec< string > PLearn::StackedLearner::getTestCostNames  )  const [virtual]
 

Returns the names of the costs computed by computeCostsFromOutpus (and thus the test method).

Implements PLearn::PLearner.

Definition at line 302 of file StackedLearner.cc.

References base_learners, and combiner.

TVec< string > PLearn::StackedLearner::getTrainCostNames  )  const [virtual]
 

Returns the names of the objective costs that the train method computes and for which it updates the VecStatsCollector train_stats.

Implements PLearn::PLearner.

Definition at line 312 of file StackedLearner.cc.

References base_learners, and combiner.

void PLearn::StackedLearner::makeDeepCopyFromShallowCopy map< const void *, void * > &  copies  )  [virtual]
 

Transforms a shallow copy into a deep copy.

Definition at line 166 of file StackedLearner.cc.

References base_learners, base_train_splitter, combiner, PLearn::deepCopyField(), and splitter.

int PLearn::StackedLearner::outputsize  )  const [virtual]
 

returns the size of this learner's output, (which typically may depend on its inputsize(), targetsize() and set options)

Implements PLearn::PLearner.

Definition at line 180 of file StackedLearner.cc.

References base_learners, and combiner.

PLearn::StackedLearner::PLEARN_DECLARE_OBJECT StackedLearner   ) 
 

void PLearn::StackedLearner::setTrainingSet VMat  training_set,
bool  call_forget = true
[virtual]
 

Declares the train_set Then calls build() and forget() if necessary.

Reimplemented from PLearn::PLearner.

Definition at line 199 of file StackedLearner.cc.

References base_learners, base_train_splitter, combiner, PLearn::TVec< PP< PLearner > >::length(), PLERROR, put_raw_input, splitter, and train_base_learners.

void PLearn::StackedLearner::setTrainStatsCollector PP< VecStatsCollector statscol  )  [virtual]
 

Sets the statistics collector whose update() method will be called during training.

Note: You shouldn't have to overload this in subclasses, except maybe to forward the call to an underlying learner.

Reimplemented from PLearn::PLearner.

Definition at line 125 of file StackedLearner.cc.

References combiner.

void PLearn::StackedLearner::train  )  [virtual]
 

The role of the train method is to bring the learner up to stage==nstages, updating the train_stats collector with training costs measured on-line in the process.

Implements PLearn::PLearner.

Definition at line 239 of file StackedLearner.cc.

References base_learners, combiner, PLearn::TVec< PP< PLearner > >::length(), normalize_base_learners_output, PLERROR, PLearn::VMat::precompute(), precompute_base_learners_output, splitter, PLearn::tostring(), and train_base_learners.


Member Data Documentation

TVec<PP<PLearner> > PLearn::StackedLearner::base_learners
 

A set of 1st level base learners that are independently trained (here or elsewhere) and whose outputs will serve as inputs to the combiner.

Definition at line 78 of file StackedLearner.h.

Referenced by build_(), computeCostsFromOutputs(), computeOutput(), forget(), getTestCostNames(), getTrainCostNames(), makeDeepCopyFromShallowCopy(), outputsize(), setTrainingSet(), and train().

Mat PLearn::StackedLearner::base_learners_outputs [protected]
 

Definition at line 63 of file StackedLearner.h.

Referenced by build_(), computeCostsFromOutputs(), and computeOutput().

PP<Splitter> PLearn::StackedLearner::base_train_splitter
 

This can be used to split the training set into different training sets for each base learner.

If it is not set, the same training set will be applied to the base learners.

Definition at line 92 of file StackedLearner.h.

Referenced by makeDeepCopyFromShallowCopy(), and setTrainingSet().

PP<PLearner> PLearn::StackedLearner::combiner
 

A learner that is trained (possibly on a data set different from the one used to train the base_learners) using the outputs of the base_learners as inputs.

Definition at line 83 of file StackedLearner.h.

Referenced by build_(), computeCostsFromOutputs(), computeOutput(), forget(), getTestCostNames(), getTrainCostNames(), makeDeepCopyFromShallowCopy(), outputsize(), setTrainingSet(), setTrainStatsCollector(), and train().

bool PLearn::StackedLearner::normalize_base_learners_output
 

If set to 1, the output of the base learners on the combiner training set will be normalized (zero mean, unit variance).

Definition at line 100 of file StackedLearner.h.

Referenced by train().

bool PLearn::StackedLearner::precompute_base_learners_output
 

If set to 1, the output of the base learners on the combiner training set will be precomputed in memory before training the combiner.

Definition at line 104 of file StackedLearner.h.

Referenced by train().

bool PLearn::StackedLearner::put_costs
 

optionally put the costs of all the learners as additional inputs of the combiner (NB: this option actually isn't implemented yet)

Definition at line 111 of file StackedLearner.h.

bool PLearn::StackedLearner::put_raw_input
 

optionally put the raw input as additional input of the combiner

Definition at line 107 of file StackedLearner.h.

Referenced by setTrainingSet().

PP<Splitter> PLearn::StackedLearner::splitter
 

This can be and which data subset(s) goes to training the combiner.

Definition at line 87 of file StackedLearner.h.

Referenced by build_(), makeDeepCopyFromShallowCopy(), setTrainingSet(), and train().

bool PLearn::StackedLearner::train_base_learners
 

whether to train the base learners in the method train (otherwise they should be initialized at construction / setOption time)

Definition at line 96 of file StackedLearner.h.

Referenced by forget(), setTrainingSet(), and train().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:27:31 2004 for PLearn by doxygen 1.3.7