GClasses

GClasses::GLinearRegressor Class Reference

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>

Inheritance diagram for GClasses::GLinearRegressor:
GClasses::GSupervisedLearner GClasses::GTransducer

List of all members.

Public Member Functions

 GLinearRegressor (GRand &rand)
 GLinearRegressor (GDomNode *pNode, GLearnerLoader &ll)
 Load from a text-format.
virtual ~GLinearRegressor ()
virtual GDomNodeserialize (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.
GMatrixbeta ()
 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

GMatrixm_pBeta
double * m_pEpsilon

Detailed Description

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.)


Constructor & Destructor Documentation

GClasses::GLinearRegressor::GLinearRegressor ( GRand rand)
GClasses::GLinearRegressor::GLinearRegressor ( GDomNode pNode,
GLearnerLoader ll 
)

Load from a text-format.

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

Member Function Documentation

void GClasses::GLinearRegressor::autoTune ( GMatrix features,
GMatrix labels 
)

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]
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]
virtual void GClasses::GLinearRegressor::predictInner ( const double *  pIn,
double *  pOut 
) [protected, virtual]
void GClasses::GLinearRegressor::refine ( GMatrix features,
GMatrix labels,
double  learningRate,
size_t  epochs,
double  learningRateDecayFactor 
)

Performs on-line gradient descent to refine the model.

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

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]

Member Data Documentation