GClasses

GClasses::GBag Class Reference

BAG stands for bootstrap aggregator. It represents an ensemble of voting modelers. Each model is trained with a slightly different training set, which is produced by drawing randomly from the original training set with replacement until we have a new training set of the same size. Each model is given equal weight in the vote. More...

#include <GEnsemble.h>

Inheritance diagram for GClasses::GBag:
GClasses::GEnsemble GClasses::GSupervisedLearner GClasses::GTransducer GClasses::GBayesianModelAveraging GClasses::GBayesianModelCombination

List of all members.

Public Member Functions

 GBag (GRand &rand)
 General-purpose constructor.
 GBag (GDomNode *pNode, GLearnerLoader &ll)
 Deserializing constructor.
virtual ~GBag ()
virtual GDomNodeserialize (GDom *pDoc)
 Marshal this object into a DOM, which can then be converted to a variety of serial formats.
virtual void clear ()
 Calls clears on all of the learners, but does not delete them.
void flush ()
 Removes and deletes all the learners.
void addLearner (GSupervisedLearner *pLearner)
 Adds a learner to the bag. This takes ownership of pLearner (so it will delete it when it's done with it)
void setProgressCallback (EnsembleProgressCallback pCB, void *pThis)
 If you want to be notified when another instance begins training, you can set this callback.

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 trainInnerInner (GMatrix &features, GMatrix &labels)
 See the comment for GEnsemble::trainInnerInner.
virtual void determineWeights (GMatrix &features, GMatrix &labels)
 Assigns uniform weight to all models. (This method is deliberately virtual so that you can overload it if you want non-uniform weighting.)

Protected Attributes

EnsembleProgressCallback m_pCB
void * m_pThis
double m_trainSize

Detailed Description

BAG stands for bootstrap aggregator. It represents an ensemble of voting modelers. Each model is trained with a slightly different training set, which is produced by drawing randomly from the original training set with replacement until we have a new training set of the same size. Each model is given equal weight in the vote.


Constructor & Destructor Documentation

GClasses::GBag::GBag ( GRand rand)

General-purpose constructor.

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

Deserializing constructor.

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

Member Function Documentation

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

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

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

Calls clears on all of the learners, but does not delete them.

Implements GClasses::GSupervisedLearner.

virtual void GClasses::GBag::determineWeights ( GMatrix features,
GMatrix labels 
) [protected, virtual]

Assigns uniform weight to all models. (This method is deliberately virtual so that you can overload it if you want non-uniform weighting.)

Reimplemented in GClasses::GBayesianModelAveraging, and GClasses::GBayesianModelCombination.

void GClasses::GBag::flush ( )

Removes and deletes all the learners.

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

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

Implements GClasses::GSupervisedLearner.

Reimplemented in GClasses::GBayesianModelAveraging, and GClasses::GBayesianModelCombination.

void GClasses::GBag::setProgressCallback ( EnsembleProgressCallback  pCB,
void *  pThis 
) [inline]

If you want to be notified when another instance begins training, you can set this callback.

static void GClasses::GBag::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::GBag::trainInnerInner ( GMatrix features,
GMatrix labels 
) [protected, virtual]

See the comment for GEnsemble::trainInnerInner.

Implements GClasses::GEnsemble.


Member Data Documentation

void* GClasses::GBag::m_pThis [protected]
double GClasses::GBag::m_trainSize [protected]