GClasses

GClasses::GBucket Class Reference

When Train is called, this performs cross-validation on the training set to determine which learner is the best. It then trains that learner with the entire training set. More...

#include <GEnsemble.h>

Inheritance diagram for GClasses::GBucket:
GClasses::GSupervisedLearner GClasses::GTransducer

List of all members.

Public Member Functions

 GBucket (GRand &rand)
 General-purpose constructor.
 GBucket (GDomNode *pNode, GLearnerLoader &ll)
 Deserializing constructor.
virtual ~GBucket ()
virtual GDomNodeserialize (GDom *pDoc)
 Marshal this object into a DOM, which can then be converted to a variety of serial formats.
virtual void clear ()
 See the comment for GSupervisedLearner::clear.
void flush ()
 Removes and deletes all the learners.
void addLearner (GSupervisedLearner *pLearner)
 Adds a modeler to the list. This takes ownership of pLearner (so it will delete it when it's done with it)
GSupervisedLearnerreleaseBestModeler ()
 Returns the modeler that did the best with the training set. It is your responsibility to delete the modeler this returns. Throws if you haven't trained yet.
virtual void onError (std::exception &e)
 If one of the algorithms throws during training, it will catch it and call this no-op method. Overload this method if you don't want to ignore exceptions.

Static Public Member Functions

static void test ()
 Runs some unit tests related to supervised learning. Throws an exception if any problems are found.

Protected Member Functions

virtual void trainInner (GMatrix &features, GMatrix &labels)
 See the comment for GSupervisedLearner::trainInner.
virtual void predictInner (const double *pIn, double *pOut)
 See the comment for GSupervisedLearner::predictInner.
virtual void predictDistributionInner (const double *pIn, GPrediction *pOut)
 See the comment for GSupervisedLearner::predictDistributionInner.

Protected Attributes

size_t m_nBestLearner
std::vector< GSupervisedLearner * > m_models

Detailed Description

When Train is called, this performs cross-validation on the training set to determine which learner is the best. It then trains that learner with the entire training set.


Constructor & Destructor Documentation

GClasses::GBucket::GBucket ( GRand rand)

General-purpose constructor.

GClasses::GBucket::GBucket ( GDomNode pNode,
GLearnerLoader ll 
)

Deserializing constructor.

virtual GClasses::GBucket::~GBucket ( ) [virtual]

Member Function Documentation

void GClasses::GBucket::addLearner ( GSupervisedLearner pLearner)

Adds a modeler to the list. This takes ownership of pLearner (so it will delete it when it's done with it)

virtual void GClasses::GBucket::clear ( ) [virtual]

See the comment for GSupervisedLearner::clear.

Implements GClasses::GSupervisedLearner.

void GClasses::GBucket::flush ( )

Removes and deletes all the learners.

virtual void GClasses::GBucket::onError ( std::exception &  e) [virtual]

If one of the algorithms throws during training, it will catch it and call this no-op method. Overload this method if you don't want to ignore exceptions.

virtual void GClasses::GBucket::predictDistributionInner ( const double *  pIn,
GPrediction pOut 
) [protected, virtual]
virtual void GClasses::GBucket::predictInner ( const double *  pIn,
double *  pOut 
) [protected, virtual]
GSupervisedLearner* GClasses::GBucket::releaseBestModeler ( )

Returns the modeler that did the best with the training set. It is your responsibility to delete the modeler this returns. Throws if you haven't trained yet.

virtual GDomNode* GClasses::GBucket::serialize ( GDom pDoc) [virtual]

Marshal this object into a DOM, which can then be converted to a variety of serial formats.

Implements GClasses::GSupervisedLearner.

static void GClasses::GBucket::test ( ) [static]

Runs some unit tests related to supervised learning. Throws an exception if any problems are found.

Reimplemented from GClasses::GSupervisedLearner.

virtual void GClasses::GBucket::trainInner ( GMatrix features,
GMatrix labels 
) [protected, virtual]

Member Data Documentation