GClasses
|
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>
Public Member Functions | |
GBucket (GRand &rand) | |
General-purpose constructor. | |
GBucket (GDomNode *pNode, GLearnerLoader &ll) | |
Deserializing constructor. | |
virtual | ~GBucket () |
virtual GDomNode * | serialize (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) | |
GSupervisedLearner * | 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 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 |
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.
GClasses::GBucket::GBucket | ( | GRand & | rand | ) |
General-purpose constructor.
GClasses::GBucket::GBucket | ( | GDomNode * | pNode, |
GLearnerLoader & | ll | ||
) |
Deserializing constructor.
virtual GClasses::GBucket::~GBucket | ( | ) | [virtual] |
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] |
See the comment for GSupervisedLearner::predictDistributionInner.
Implements GClasses::GSupervisedLearner.
virtual void GClasses::GBucket::predictInner | ( | const double * | pIn, |
double * | pOut | ||
) | [protected, virtual] |
See the comment for GSupervisedLearner::predictInner.
Implements GClasses::GSupervisedLearner.
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.
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] |
See the comment for GSupervisedLearner::trainInner.
Implements GClasses::GSupervisedLearner.
std::vector<GSupervisedLearner*> GClasses::GBucket::m_models [protected] |
size_t GClasses::GBucket::m_nBestLearner [protected] |