GClasses
|
This is the base class of supervised learning algorithms that can learn one row at a time. More...
#include <GLearner.h>
Public Member Functions | |
GIncrementalLearner (GRand &rand) | |
General-purpose constructor. | |
GIncrementalLearner (GDomNode *pNode, GLearnerLoader &ll) | |
Deserialization constructor. | |
virtual | ~GIncrementalLearner () |
Destructor. | |
virtual bool | isFilter () |
Only the GFilter class should return true to this method. | |
virtual bool | canTrainIncrementally () |
Returns true. | |
void | beginIncrementalLearning (sp_relation &pFeatureRel, sp_relation &pLabelRel) |
You must call this method before you call trainIncremental. Unlike "train", this method does not automatically set up any filters (even if you have automatic filter setup enabled). Rather, it assumes that you have already set up any filters that you wish to use. Behavior is undefined if you change the filters (by calling setFeatureFilter or setLabelFilter, or by changing the filters themselves) after this method is called. | |
void | trainIncremental (const double *pIn, const double *pOut) |
Pass a single input row and the corresponding label to incrementally train this model. | |
virtual void | trainSparse (GSparseMatrix &features, GMatrix &labels)=0 |
Train using a sparse feature matrix. (A Typical implementation of this method will first call beginIncrementalLearning, then it will iterate over all of the feature rows, and for each row it will convert the sparse row to a dense row, call trainIncremental using the dense row, then discard the dense row and proceed to the next row.) | |
Protected Member Functions | |
virtual void | beginIncrementalLearningInner (sp_relation &pFeatureRel, sp_relation &pLabelRel)=0 |
Prepare the model for incremental learning. | |
virtual void | trainIncrementalInner (const double *pIn, const double *pOut)=0 |
Refine the model with the specified pattern. |
This is the base class of supervised learning algorithms that can learn one row at a time.
GClasses::GIncrementalLearner::GIncrementalLearner | ( | GRand & | rand | ) | [inline] |
General-purpose constructor.
GClasses::GIncrementalLearner::GIncrementalLearner | ( | GDomNode * | pNode, |
GLearnerLoader & | ll | ||
) | [inline] |
Deserialization constructor.
virtual GClasses::GIncrementalLearner::~GIncrementalLearner | ( | ) | [inline, virtual] |
Destructor.
void GClasses::GIncrementalLearner::beginIncrementalLearning | ( | sp_relation & | pFeatureRel, |
sp_relation & | pLabelRel | ||
) |
You must call this method before you call trainIncremental. Unlike "train", this method does not automatically set up any filters (even if you have automatic filter setup enabled). Rather, it assumes that you have already set up any filters that you wish to use. Behavior is undefined if you change the filters (by calling setFeatureFilter or setLabelFilter, or by changing the filters themselves) after this method is called.
virtual void GClasses::GIncrementalLearner::beginIncrementalLearningInner | ( | sp_relation & | pFeatureRel, |
sp_relation & | pLabelRel | ||
) | [protected, pure virtual] |
Prepare the model for incremental learning.
Implemented in GClasses::GKNN, GClasses::GInstanceTable, GClasses::GNaiveBayes, GClasses::GNaiveInstance, and GClasses::GNeuralNet.
virtual bool GClasses::GIncrementalLearner::canTrainIncrementally | ( | ) | [inline, virtual] |
Returns true.
Reimplemented from GClasses::GTransducer.
virtual bool GClasses::GIncrementalLearner::isFilter | ( | ) | [inline, virtual] |
Only the GFilter class should return true to this method.
void GClasses::GIncrementalLearner::trainIncremental | ( | const double * | pIn, |
const double * | pOut | ||
) |
Pass a single input row and the corresponding label to incrementally train this model.
virtual void GClasses::GIncrementalLearner::trainIncrementalInner | ( | const double * | pIn, |
const double * | pOut | ||
) | [protected, pure virtual] |
Refine the model with the specified pattern.
Implemented in GClasses::GKNN, GClasses::GInstanceTable, GClasses::GNaiveBayes, GClasses::GNaiveInstance, and GClasses::GNeuralNet.
virtual void GClasses::GIncrementalLearner::trainSparse | ( | GSparseMatrix & | features, |
GMatrix & | labels | ||
) | [pure virtual] |
Train using a sparse feature matrix. (A Typical implementation of this method will first call beginIncrementalLearning, then it will iterate over all of the feature rows, and for each row it will convert the sparse row to a dense row, call trainIncremental using the dense row, then discard the dense row and proceed to the next row.)
Implemented in GClasses::GKNN, GClasses::GInstanceTable, GClasses::GNaiveBayes, GClasses::GNaiveInstance, and GClasses::GNeuralNet.