GClasses
|
A linear regression model. Let f be a feature vector of real values, and let l be a label vector of real values, then this model estimates l=Bf+e, where B is a matrix of real values, and e is a vector of real values. (In the Wikipedia article on linear regression, B is called "beta", and e is called "epsilon". The approach used by this model to compute beta and epsilon, however, is much more efficient than the approach currently described in that article.) More...
#include <GLinear.h>
Public Member Functions | |
GLinearRegressor (GRand &rand) | |
GLinearRegressor (GDomNode *pNode, GLearnerLoader &ll) | |
Load from a text-format. | |
virtual | ~GLinearRegressor () |
virtual GDomNode * | serialize (GDom *pDoc) |
Saves the model to a text file. (This doesn't save the short-term memory used for incremental learning, so if you're doing "incremental" learning, it will wake up with amnesia when you load it again.) | |
virtual void | clear () |
See the comment for GSupervisedLearner::clear. | |
GMatrix * | beta () |
Returns the matrix that represents the linear transformation. | |
double * | epsilon () |
Returns the vector that is added to the results after the linear transformation is applied. | |
void | refine (GMatrix &features, GMatrix &labels, double learningRate, size_t epochs, double learningRateDecayFactor) |
Performs on-line gradient descent to refine the model. | |
void | autoTune (GMatrix &features, GMatrix &labels) |
This model has no parameters to tune, so this method is a noop. | |
Static Public Member Functions | |
static void | test () |
Performs unit tests for this class. Throws an exception if there is a failure. | |
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. | |
virtual bool | canImplicitlyHandleNominalFeatures () |
See the comment for GTransducer::canImplicitlyHandleNominalFeatures. | |
virtual bool | canImplicitlyHandleNominalLabels () |
See the comment for GTransducer::canImplicitlyHandleNominalLabels. | |
Protected Attributes | |
GMatrix * | m_pBeta |
double * | m_pEpsilon |
A linear regression model. Let f be a feature vector of real values, and let l be a label vector of real values, then this model estimates l=Bf+e, where B is a matrix of real values, and e is a vector of real values. (In the Wikipedia article on linear regression, B is called "beta", and e is called "epsilon". The approach used by this model to compute beta and epsilon, however, is much more efficient than the approach currently described in that article.)
GClasses::GLinearRegressor::GLinearRegressor | ( | GRand & | rand | ) |
GClasses::GLinearRegressor::GLinearRegressor | ( | GDomNode * | pNode, |
GLearnerLoader & | ll | ||
) |
Load from a text-format.
virtual GClasses::GLinearRegressor::~GLinearRegressor | ( | ) | [virtual] |
This model has no parameters to tune, so this method is a noop.
GMatrix* GClasses::GLinearRegressor::beta | ( | ) | [inline] |
Returns the matrix that represents the linear transformation.
virtual bool GClasses::GLinearRegressor::canImplicitlyHandleNominalFeatures | ( | ) | [inline, protected, virtual] |
See the comment for GTransducer::canImplicitlyHandleNominalFeatures.
Reimplemented from GClasses::GTransducer.
virtual bool GClasses::GLinearRegressor::canImplicitlyHandleNominalLabels | ( | ) | [inline, protected, virtual] |
See the comment for GTransducer::canImplicitlyHandleNominalLabels.
Reimplemented from GClasses::GTransducer.
virtual void GClasses::GLinearRegressor::clear | ( | ) | [virtual] |
See the comment for GSupervisedLearner::clear.
Implements GClasses::GSupervisedLearner.
double* GClasses::GLinearRegressor::epsilon | ( | ) | [inline] |
Returns the vector that is added to the results after the linear transformation is applied.
virtual void GClasses::GLinearRegressor::predictDistributionInner | ( | const double * | pIn, |
GPrediction * | pOut | ||
) | [protected, virtual] |
See the comment for GSupervisedLearner::predictDistributionInner.
Implements GClasses::GSupervisedLearner.
virtual void GClasses::GLinearRegressor::predictInner | ( | const double * | pIn, |
double * | pOut | ||
) | [protected, virtual] |
See the comment for GSupervisedLearner::predictInner.
Implements GClasses::GSupervisedLearner.
void GClasses::GLinearRegressor::refine | ( | GMatrix & | features, |
GMatrix & | labels, | ||
double | learningRate, | ||
size_t | epochs, | ||
double | learningRateDecayFactor | ||
) |
Performs on-line gradient descent to refine the model.
Saves the model to a text file. (This doesn't save the short-term memory used for incremental learning, so if you're doing "incremental" learning, it will wake up with amnesia when you load it again.)
Implements GClasses::GSupervisedLearner.
static void GClasses::GLinearRegressor::test | ( | ) | [static] |
Performs unit tests for this class. Throws an exception if there is a failure.
Reimplemented from GClasses::GSupervisedLearner.
virtual void GClasses::GLinearRegressor::trainInner | ( | GMatrix & | features, |
GMatrix & | labels | ||
) | [protected, virtual] |
See the comment for GSupervisedLearner::trainInner.
Implements GClasses::GSupervisedLearner.
GMatrix* GClasses::GLinearRegressor::m_pBeta [protected] |
double* GClasses::GLinearRegressor::m_pEpsilon [protected] |