GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
GRT::LinearRegression Class Reference
Inheritance diagram for GRT::LinearRegression:
GRT::Regressifier GRT::MLBase GRT::GRTBase GRT::Observer< TrainingResult > GRT::Observer< TestInstanceResult >

Public Member Functions

 LinearRegression (bool useScaling=false)
 
virtual ~LinearRegression (void)
 
LinearRegressionoperator= (const LinearRegression &rhs)
 
virtual bool deepCopyFrom (const Regressifier *regressifier)
 
virtual bool train_ (RegressionData &trainingData)
 
virtual bool predict_ (VectorDouble &inputVector)
 
virtual bool saveModelToFile (fstream &file) const
 
virtual bool loadModelFromFile (fstream &file)
 
UINT getMaxNumIterations () const
 
bool setMaxNumIterations (const UINT maxNumIterations)
 
- Public Member Functions inherited from GRT::Regressifier
 Regressifier (void)
 
virtual ~Regressifier (void)
 
bool copyBaseVariables (const Regressifier *regressifier)
 
virtual bool reset ()
 
virtual bool clear ()
 
string getRegressifierType () const
 
VectorDouble getRegressionData () const
 
vector< MinMaxgetInputRanges () const
 
vector< MinMaxgetOutputRanges () const
 
RegressifiercreateNewInstance () const
 
RegressifierdeepCopy () const
 
const RegressifiergetBaseRegressifier () const
 
- Public Member Functions inherited from GRT::MLBase
 MLBase (void)
 
virtual ~MLBase (void)
 
bool copyMLBaseVariables (const MLBase *mlBase)
 
virtual bool train (ClassificationData trainingData)
 
virtual bool train_ (ClassificationData &trainingData)
 
virtual bool train (RegressionData trainingData)
 
virtual bool train (TimeSeriesClassificationData trainingData)
 
virtual bool train_ (TimeSeriesClassificationData &trainingData)
 
virtual bool train (TimeSeriesClassificationDataStream trainingData)
 
virtual bool train_ (TimeSeriesClassificationDataStream &trainingData)
 
virtual bool train (UnlabelledData trainingData)
 
virtual bool train_ (UnlabelledData &trainingData)
 
virtual bool train (MatrixDouble data)
 
virtual bool train_ (MatrixDouble &data)
 
virtual bool predict (VectorDouble inputVector)
 
virtual bool predict (MatrixDouble inputMatrix)
 
virtual bool predict_ (MatrixDouble &inputMatrix)
 
virtual bool map (VectorDouble inputVector)
 
virtual bool map_ (VectorDouble &inputVector)
 
virtual bool print () const
 
virtual bool save (const string filename) const
 
virtual bool load (const string filename)
 
virtual bool saveModelToFile (string filename) const
 
virtual bool loadModelFromFile (string filename)
 
virtual bool getModel (ostream &stream) const
 
double scale (const double &x, const double &minSource, const double &maxSource, const double &minTarget, const double &maxTarget, const bool constrain=false)
 
virtual string getModelAsString () const
 
UINT getBaseType () const
 
UINT getNumInputFeatures () const
 
UINT getNumInputDimensions () const
 
UINT getNumOutputDimensions () const
 
UINT getMinNumEpochs () const
 
UINT getMaxNumEpochs () const
 
UINT getValidationSetSize () const
 
UINT getNumTrainingIterationsToConverge () const
 
double getMinChange () const
 
double getLearningRate () const
 
double getRootMeanSquaredTrainingError () const
 
double getTotalSquaredTrainingError () const
 
bool getUseValidationSet () const
 
bool getRandomiseTrainingOrder () const
 
bool getTrained () const
 
bool getModelTrained () const
 
bool getScalingEnabled () const
 
bool getIsBaseTypeClassifier () const
 
bool getIsBaseTypeRegressifier () const
 
bool getIsBaseTypeClusterer () const
 
bool enableScaling (bool useScaling)
 
bool setMaxNumEpochs (const UINT maxNumEpochs)
 
bool setMinNumEpochs (const UINT minNumEpochs)
 
bool setMinChange (const double minChange)
 
bool setLearningRate (double learningRate)
 
bool setUseValidationSet (const bool useValidationSet)
 
bool setValidationSetSize (const UINT validationSetSize)
 
bool setRandomiseTrainingOrder (const bool randomiseTrainingOrder)
 
bool registerTrainingResultsObserver (Observer< TrainingResult > &observer)
 
bool registerTestResultsObserver (Observer< TestInstanceResult > &observer)
 
bool removeTrainingResultsObserver (const Observer< TrainingResult > &observer)
 
bool removeTestResultsObserver (const Observer< TestInstanceResult > &observer)
 
bool removeAllTrainingObservers ()
 
bool removeAllTestObservers ()
 
bool notifyTrainingResultsObservers (const TrainingResult &data)
 
bool notifyTestResultsObservers (const TestInstanceResult &data)
 
MLBasegetMLBasePointer ()
 
const MLBasegetMLBasePointer () const
 
vector< TrainingResultgetTrainingResults () const
 
- Public Member Functions inherited from GRT::GRTBase
 GRTBase (void)
 
virtual ~GRTBase (void)
 
bool copyGRTBaseVariables (const GRTBase *GRTBase)
 
string getClassType () const
 
string getLastWarningMessage () const
 
string getLastErrorMessage () const
 
string getLastInfoMessage () const
 
GRTBasegetGRTBasePointer ()
 
const GRTBasegetGRTBasePointer () const
 
- Public Member Functions inherited from GRT::Observer< TrainingResult >
virtual void notify (const TrainingResult &data)
 
- Public Member Functions inherited from GRT::Observer< TestInstanceResult >
virtual void notify (const TestInstanceResult &data)
 

Protected Member Functions

bool loadLegacyModelFromFile (fstream &file)
 
- Protected Member Functions inherited from GRT::Regressifier
bool saveBaseSettingsToFile (fstream &file) const
 
bool loadBaseSettingsFromFile (fstream &file)
 
- Protected Member Functions inherited from GRT::MLBase
bool saveBaseSettingsToFile (fstream &file) const
 
bool loadBaseSettingsFromFile (fstream &file)
 
- Protected Member Functions inherited from GRT::GRTBase
double SQR (const double &x) const
 

Protected Attributes

double w0
 
VectorDouble w
 
- Protected Attributes inherited from GRT::Regressifier
string regressifierType
 
VectorDouble regressionData
 
vector< MinMaxinputVectorRanges
 
vector< MinMaxtargetVectorRanges
 
- Protected Attributes inherited from GRT::MLBase
bool trained
 
bool useScaling
 
UINT baseType
 
UINT numInputDimensions
 
UINT numOutputDimensions
 
UINT numTrainingIterationsToConverge
 
UINT minNumEpochs
 
UINT maxNumEpochs
 
UINT validationSetSize
 
double learningRate
 
double minChange
 
double rootMeanSquaredTrainingError
 
double totalSquaredTrainingError
 
bool useValidationSet
 
bool randomiseTrainingOrder
 
Random random
 
vector< TrainingResulttrainingResults
 
TrainingResultsObserverManager trainingResultsObserverManager
 
TestResultsObserverManager testResultsObserverManager
 
- Protected Attributes inherited from GRT::GRTBase
string classType
 
DebugLog debugLog
 
ErrorLog errorLog
 
InfoLog infoLog
 
TrainingLog trainingLog
 
TestingLog testingLog
 
WarningLog warningLog
 

Static Protected Attributes

static RegisterRegressifierModule< LinearRegressionregisterModule
 

Additional Inherited Members

- Public Types inherited from GRT::Regressifier
typedef std::map< string, Regressifier *(*)() > StringRegressifierMap
 
- Public Types inherited from GRT::MLBase
enum  BaseTypes { BASE_TYPE_NOT_SET =0, CLASSIFIER, REGRESSIFIER, CLUSTERER }
 
- Static Public Member Functions inherited from GRT::Regressifier
static RegressifiercreateInstanceFromString (string const &regressifierType)
 
static vector< string > getRegisteredRegressifiers ()
 
- Static Public Member Functions inherited from GRT::GRTBase
static string getGRTVersion (bool returnRevision=true)
 
static string getGRTRevison ()
 
- Static Protected Member Functions inherited from GRT::Regressifier
static StringRegressifierMapgetMap ()
 

Detailed Description

Definition at line 40 of file LinearRegression.h.

Constructor & Destructor Documentation

GRT::LinearRegression::LinearRegression ( bool  useScaling = false)

Default Constructor

Parameters
booluseScaling: sets if the training and real-time data should be scaled between [0 1]. Default value = false

Definition at line 30 of file LinearRegression.cpp.

GRT::LinearRegression::~LinearRegression ( void  )
virtual

Default Destructor

Definition at line 44 of file LinearRegression.cpp.

Member Function Documentation

bool GRT::LinearRegression::deepCopyFrom ( const Regressifier regressifier)
virtual

This is required for the Gesture Recognition Pipeline for when the pipeline.setRegressifier(...) method is called. It clones the data from the Base Class Regressifier pointer (which should be pointing to an Logistic Regression instance) into this instance

Parameters
Regressifier*regressifier: a pointer to the Regressifier Base Class, this should be pointing to another Logistic Regression instance
Returns
returns true if the clone was successfull, false otherwise

Reimplemented from GRT::Regressifier.

Definition at line 59 of file LinearRegression.cpp.

UINT GRT::LinearRegression::getMaxNumIterations ( ) const

Gets the current maxNumIterations value, this is the maximum number of iterations that can be run during the training phase.

Returns
returns the maxNumIterations value

Definition at line 318 of file LinearRegression.cpp.

bool GRT::LinearRegression::loadLegacyModelFromFile ( fstream &  file)
protected

Read the ranges if needed

Definition at line 322 of file LinearRegression.cpp.

bool GRT::LinearRegression::loadModelFromFile ( fstream &  file)
virtual

This loads a trained Logistic Regression model from a file. This overrides the loadModelFromFile function in the Logistic Regression base class.

Parameters
fstream&file: a reference to the file the Logistic Regression model will be loaded from
Returns
returns true if the model was loaded successfully, false otherwise

Reimplemented from GRT::MLBase.

Definition at line 261 of file LinearRegression.cpp.

LinearRegression & GRT::LinearRegression::operator= ( const LinearRegression rhs)

Defines how the data from the rhs LinearRegression should be copied to this LinearRegression

Parameters
constLRC &rhs: another instance of a LinearRegression
Returns
returns a pointer to this instance of the LinearRegression

Definition at line 48 of file LinearRegression.cpp.

bool GRT::LinearRegression::predict_ ( VectorDouble &  inputVector)
virtual

This performs the regression by mapping the inputVector using the current Logistic Regression model. This overrides the predict function in the Regressifier base class.

Parameters
VectorDouble&inputVector: the input vector to classify
Returns
returns true if the prediction was performed, false otherwise

Reimplemented from GRT::MLBase.

Definition at line 198 of file LinearRegression.cpp.

bool GRT::LinearRegression::saveModelToFile ( fstream &  file) const
virtual

This saves the trained Logistic Regression model to a file. This overrides the saveModelToFile function in the ML base class.

Parameters
fstream&file: a reference to the file the Logistic Regression model will be saved to
Returns
returns true if the model was saved successfully, false otherwise

Reimplemented from GRT::MLBase.

Definition at line 232 of file LinearRegression.cpp.

bool GRT::LinearRegression::setMaxNumIterations ( const UINT  maxNumIterations)

Sets the maximum number of iterations that can be run during the training phase. The maxNumIterations value must be greater than zero.

Parameters
constUINT maxNumIterations: the maximum number of iterations value, must be greater than zero
Returns
returns true if the value was updated successfully, false otherwise

Definition at line 314 of file LinearRegression.cpp.

bool GRT::LinearRegression::train_ ( RegressionData trainingData)
virtual

This trains the Logistic Regression model, using the labelled regression data. This overrides the train function in the Regression base class.

Parameters
RegressionData&trainingData: the training data that will be used to train the regression model
Returns
returns true if the LRC model was trained, false otherwise

Reimplemented from GRT::MLBase.

Definition at line 76 of file LinearRegression.cpp.


The documentation for this class was generated from the following files: