GestureRecognitionToolkit  Version: 0.2.5
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
MLBase Class Reference

This is the main base class that all GRT machine learning algorithms should inherit from. More...

#include <MLBase.h>

Inheritance diagram for MLBase:
GRTBase Observer< TrainingResult > Observer< TestInstanceResult > BernoulliRBM Classifier Clusterer Context ContinuousHiddenMarkovModel DiscreteHiddenMarkovModel EvolutionaryAlgorithm< INDIVIDUAL > FeatureExtraction GestureRecognitionPipeline GridSearch< T > LinearLeastSquares MeanShift MovementDetector Node PostProcessing PreProcessing PrincipalComponentAnalysis Regressifier Tree

Public Types

enum  BaseType {
  BASE_TYPE_NOT_SET =0, CLASSIFIER, REGRESSIFIER, CLUSTERER,
  PRE_PROCSSING, POST_PROCESSING, FEATURE_EXTRACTION, CONTEXT
}
 

Public Member Functions

 MLBase (const std::string &id="", const BaseType type=BASE_TYPE_NOT_SET)
 
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_ (RegressionData &trainingData)
 
virtual bool train (RegressionData trainingData, RegressionData validationData)
 
virtual bool train_ (RegressionData &trainingData, RegressionData &validationData)
 
virtual bool train (TimeSeriesClassificationData trainingData)
 
virtual bool train_ (TimeSeriesClassificationData &trainingData)
 
virtual bool train (ClassificationDataStream trainingData)
 
virtual bool train_ (ClassificationDataStream &trainingData)
 
virtual bool train (UnlabelledData trainingData)
 
virtual bool train_ (UnlabelledData &trainingData)
 
virtual bool train (MatrixFloat data)
 
virtual bool train_ (MatrixFloat &data)
 
virtual bool predict (VectorFloat inputVector)
 
virtual bool predict_ (VectorFloat &inputVector)
 
virtual bool predict (MatrixFloat inputMatrix)
 
virtual bool predict_ (MatrixFloat &inputMatrix)
 
virtual bool map (VectorFloat inputVector)
 
virtual bool map_ (VectorFloat &inputVector)
 
virtual bool reset ()
 
virtual bool clear ()
 
virtual bool print () const
 
virtual bool save (const std::string &filename) const
 
virtual bool load (const std::string &filename)
 
virtual bool save (std::fstream &file) const
 
virtual bool load (std::fstream &file)
 
 GRT_DEPRECATED_MSG ("saveModelToFile(std::string filename) is deprecated, use save(const std::string &filename) instead", virtual bool saveModelToFile(const std::string &filename) const )
 
 GRT_DEPRECATED_MSG ("saveModelToFile(std::fstream &file) is deprecated, use save(std::fstream &file) instead", virtual bool saveModelToFile(std::fstream &file) const )
 
 GRT_DEPRECATED_MSG ("loadModelFromFile(std::string filename) is deprecated, use load(const std::string &filename) instead", virtual bool loadModelFromFile(const std::string &filename))
 
 GRT_DEPRECATED_MSG ("loadModelFromFile(std::fstream &file) is deprecated, use load(std::fstream &file) instead", virtual bool loadModelFromFile(std::fstream &file))
 
virtual bool getModel (std::ostream &stream) const
 
virtual std::string getModelAsString () const
 
DataType getInputType () const
 
DataType getOutputType () const
 
BaseType getType () const
 
UINT getNumInputFeatures () const
 
UINT getNumInputDimensions () const
 
UINT getNumOutputDimensions () const
 
UINT getMinNumEpochs () const
 
UINT getMaxNumEpochs () const
 
UINT getBatchSize () const
 
UINT getNumRestarts () const
 
UINT getValidationSetSize () const
 
UINT getNumTrainingIterationsToConverge () const
 
Float getMinChange () const
 
Float getLearningRate () const
 
Float getRMSTrainingError () const
 
 GRT_DEPRECATED_MSG ("getRootMeanSquaredTrainingError() is deprecated, use getRMSTrainingError() instead", Float getRootMeanSquaredTrainingError() const )
 
Float getTotalSquaredTrainingError () const
 
Float getRMSValidationError () const
 
Float getValidationSetAccuracy () const
 
VectorFloat getValidationSetPrecision () const
 
VectorFloat getValidationSetRecall () const
 
bool getUseValidationSet () const
 
bool getRandomiseTrainingOrder () const
 
bool getTrained () const
 
 GRT_DEPRECATED_MSG ("getModelTrained() is deprecated, use getTrained() instead", bool getModelTrained() const )
 
bool getConverged () const
 
bool getScalingEnabled () const
 
bool getIsBaseTypeClassifier () const
 
bool getIsBaseTypeRegressifier () const
 
bool getIsBaseTypeClusterer () const
 
bool getTrainingLoggingEnabled () const
 
bool getTestingLoggingEnabled () const
 
bool enableScaling (const bool useScaling)
 
bool setMaxNumEpochs (const UINT maxNumEpochs)
 
bool setBatchSize (const UINT batchSize)
 
bool setMinNumEpochs (const UINT minNumEpochs)
 
bool setNumRestarts (const UINT numRestarts)
 
bool setMinChange (const Float minChange)
 
bool setLearningRate (const Float learningRate)
 
bool setUseValidationSet (const bool useValidationSet)
 
bool setValidationSetSize (const UINT validationSetSize)
 
bool setRandomiseTrainingOrder (const bool randomiseTrainingOrder)
 
bool setTrainingLoggingEnabled (const bool loggingEnabled)
 
bool setTestingLoggingEnabled (const bool loggingEnabled)
 
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 GRTBase
 GRTBase (const std::string &id="")
 
virtual ~GRTBase (void)
 
bool copyGRTBaseVariables (const GRTBase *GRTBase)
 
 GRT_DEPRECATED_MSG ("getClassType is deprecated, use getId() instead!", std::string getClassType() const )
 
std::string getId () const
 
std::string getLastWarningMessage () const
 
std::string getLastErrorMessage () const
 
std::string getLastInfoMessage () const
 
bool setInfoLoggingEnabled (const bool loggingEnabled)
 
bool setWarningLoggingEnabled (const bool loggingEnabled)
 
bool setErrorLoggingEnabled (const bool loggingEnabled)
 
bool setDebugLoggingEnabled (const bool loggingEnabled)
 
GRTBasegetGRTBasePointer ()
 
const GRTBasegetGRTBasePointer () const
 
Float scale (const Float &x, const Float &minSource, const Float &maxSource, const Float &minTarget, const Float &maxTarget, const bool constrain=false)
 
Float SQR (const Float &x) const
 
- Public Member Functions inherited from Observer< TrainingResult >
virtual void notify (const TrainingResult &data)
 
- Public Member Functions inherited from Observer< TestInstanceResult >
virtual void notify (const TestInstanceResult &data)
 

Protected Member Functions

bool saveBaseSettingsToFile (std::fstream &file) const
 
bool loadBaseSettingsFromFile (std::fstream &file)
 

Protected Attributes

bool trained
 
bool useScaling
 
bool converged
 
DataType inputType
 
DataType outputType
 
BaseType baseType
 
UINT numInputDimensions
 
UINT numOutputDimensions
 
UINT numTrainingIterationsToConverge
 
UINT minNumEpochs
 
UINT maxNumEpochs
 
UINT batchSize
 
UINT validationSetSize
 
UINT numRestarts
 
Float learningRate
 
Float minChange
 
Float rmsTrainingError
 
Float rmsValidationError
 
Float totalSquaredTrainingError
 
Float validationSetAccuracy
 
bool useValidationSet
 
bool randomiseTrainingOrder
 
VectorFloat validationSetPrecision
 
VectorFloat validationSetRecall
 
Random random
 
Vector< TrainingResulttrainingResults
 
TrainingResultsObserverManager trainingResultsObserverManager
 
TestResultsObserverManager testResultsObserverManager
 
TrainingLog trainingLog
 
TestingLog testingLog
 
- Protected Attributes inherited from GRTBase
std::string classId
 Stores the name of the class (e.g., MinDist)
 
DebugLog debugLog
 
ErrorLog errorLog
 
InfoLog infoLog
 
WarningLog warningLog
 

Additional Inherited Members

- Static Public Member Functions inherited from GRTBase
static std::string getGRTVersion (bool returnRevision=true)
 
static std::string getGRTRevison ()
 

Detailed Description

This is the main base class that all GRT machine learning algorithms should inherit from.

A large number of the functions in this class are virtual and simply return false as these functions must be overwridden by the inheriting class.

Definition at line 72 of file MLBase.h.

Constructor & Destructor Documentation

GRT_BEGIN_NAMESPACE MLBase::MLBase ( const std::string &  id = "",
const BaseType  type = BASE_TYPE_NOT_SET 
)

Default MLBase Constructor

Parameters
idthe id of the inheriting class
typethe type of the inheriting class (e.g., classifier, regressifier, etc.)

Definition at line 26 of file MLBase.cpp.

MLBase::~MLBase ( void  )
virtual

Default MLBase Destructor

Definition at line 58 of file MLBase.cpp.

Member Function Documentation

bool MLBase::clear ( )
virtual

This is the main clear interface for all the GRT machine learning algorithms. It will completely clear the ML module, removing any trained model and setting all the base variables to their default values.

Returns
returns true if the derived class was cleared succesfully, false otherwise

Reimplemented in GestureRecognitionPipeline, SelfOrganizingMap, DTW, HierarchicalClustering, HMM, FFT, FiniteStateMachine, AdaBoost, ANBC, KNN, SVM, RandomForests, DecisionTree, BAG, ClusterTreeNode, FIRFilter, RegressionTreeNode, RBMQuantizer, GMM, ParticleClassifier, KMeansQuantizer, SOMQuantizer, MLP, ClusterTree, Softmax, SwipeDetector, RegressionTree, MinDist, Clusterer, BernoulliRBM, DecisionTreeNode, Node, KMeans, FeatureExtraction, PreProcessing, GaussianMixtureModels, Classifier, Regressifier, DecisionTreeClusterNode, DecisionTreeThresholdNode, ContinuousHiddenMarkovModel, DecisionTreeTripleFeatureNode, Tree, LinearLeastSquares, and MovementDetector.

Definition at line 149 of file MLBase.cpp.

bool MLBase::copyMLBaseVariables ( const MLBase mlBase)

This copies all the MLBase variables from the instance mlBaseA to the instance mlBaseA.

Parameters
mlBasea pointer to a MLBase class from which the values will be copied to the instance that calls the function
Returns
returns true if the copy was successfull, false otherwise

Definition at line 62 of file MLBase.cpp.

bool MLBase::enableScaling ( const bool  useScaling)

Sets if scaling should be used during the training and prediction phases.

Returns
returns true the scaling parameter was updated, false otherwise
Examples:
ClassificationModulesExamples/ANBCExample/ANBCExample.cpp, ClassificationModulesExamples/KNNExample/KNNExample.cpp, ClassificationModulesExamples/SVMExample/SVMExample.cpp, and RegressionModulesExamples/MLPRegressionExample/MLPRegressionExample.cpp.

Definition at line 308 of file MLBase.cpp.

UINT MLBase::getBatchSize ( ) const

Gets the batch size. This value controls the number of samples that can be used by the training algorithm.

Returns
returns the batch size

Definition at line 250 of file MLBase.cpp.

bool MLBase::getConverged ( ) const

Returns true if the training algorithm converged during the most recent training process. This function will return false if the model has not been trained.

Returns
returns true if the training algorithm converged succesfully, false otherwise

Definition at line 298 of file MLBase.cpp.

DataType MLBase::getInputType ( ) const

Gets the expected input data type for the module

Returns
returns the expected input data type

Definition at line 223 of file MLBase.cpp.

bool MLBase::getIsBaseTypeClassifier ( ) const

Gets if the derived class type is CLASSIFIER.

Returns
returns true if the derived class type is CLASSIFIER, false otherwise

Definition at line 302 of file MLBase.cpp.

bool MLBase::getIsBaseTypeClusterer ( ) const

Gets if the derived class type is CLUSTERER.

Returns
returns true if the derived class type is CLUSTERER, false otherwise

Definition at line 306 of file MLBase.cpp.

bool MLBase::getIsBaseTypeRegressifier ( ) const

Gets if the derived class type is REGRESSIFIER.

Returns
returns true if the derived class type is REGRESSIFIER, false otherwise

Definition at line 304 of file MLBase.cpp.

Float MLBase::getLearningRate ( ) const

Gets the current learningRate value, this is value used to update the weights at each step of a learning algorithm such as stochastic gradient descent.

Returns
returns the current learningRate value

Definition at line 262 of file MLBase.cpp.

UINT MLBase::getMaxNumEpochs ( ) const

Gets the maximum number of epochs. This value controls the maximum number of epochs that can be used by the training algorithm. An epoch is a complete iteration of all training samples.

Returns
returns the maximum number of epochs

Definition at line 246 of file MLBase.cpp.

Float MLBase::getMinChange ( ) const

Gets the minimum change value that controls when the training algorithm should stop.

Returns
returns the minimum change value
UINT MLBase::getMinNumEpochs ( ) const

Gets the minimum number of epochs. This is the minimum number of epochs that can elapse with no change between two training epochs. An epoch is a complete iteration of all training samples.

Returns
returns the minimum number of epochs

Definition at line 242 of file MLBase.cpp.

MLBase * MLBase::getMLBasePointer ( )

This functions returns a pointer to the current instance.

Returns
returns a MLBase pointer to the current instance.

Definition at line 423 of file MLBase.cpp.

const MLBase * MLBase::getMLBasePointer ( ) const

This functions returns a const pointer to the current instance.

Returns
returns a const MLBase pointer to the current instance.

Definition at line 427 of file MLBase.cpp.

bool MLBase::getModel ( std::ostream &  stream) const
virtual

This function adds the current model to the formatted stream. This function should be overwritten by the derived class.

Parameters
filea reference to the stream the model will be added to
Returns
returns true if the model was added successfully, false otherwise

Reimplemented in DecisionTree, Node, DecisionTreeClusterNode, DecisionTreeNode, DecisionTreeThresholdNode, DecisionTreeTripleFeatureNode, and Tree.

Definition at line 213 of file MLBase.cpp.

std::string MLBase::getModelAsString ( ) const
virtual

Gets the current model and settings as a std::string.

Returns
returns a std::string containing the model

Reimplemented in GestureRecognitionPipeline.

Definition at line 215 of file MLBase.cpp.

UINT MLBase::getNumInputDimensions ( ) const

Gets the number of input dimensions in trained model.

Returns
returns the number of input dimensions

Definition at line 231 of file MLBase.cpp.

UINT MLBase::getNumInputFeatures ( ) const

Gets the number of input dimensions in trained model. This function is now depriciated and will be removed in the future, you should use getNumInputDimensions instead.

Returns
returns the number of input dimensions in the trained model, a value of 0 will be returned if the model has not been trained

Definition at line 229 of file MLBase.cpp.

UINT MLBase::getNumOutputDimensions ( ) const

Gets the number of output dimensions in trained model.

Returns
returns the number of output dimensions

Definition at line 233 of file MLBase.cpp.

UINT MLBase::getNumRestarts ( ) const

Gets the number of times a learning algorithm can restart during training.

Returns
returns the number of times a learning algorithm can restart during training

Definition at line 254 of file MLBase.cpp.

UINT MLBase::getNumTrainingIterationsToConverge ( ) const

Gets the number of training iterations that were required for the algorithm to converge.

Returns
returns the number of training iterations required for the training algorithm to converge, a value of 0 will be returned if the model has not been trained
Examples:
ClusteringModulesExamples/GaussianMixtureModelsExample/GaussianMixtureModelsExample.cpp.

Definition at line 235 of file MLBase.cpp.

DataType MLBase::getOutputType ( ) const

Gets the expected output data type for the module

Returns
returns the expected output data type

Definition at line 225 of file MLBase.cpp.

bool MLBase::getRandomiseTrainingOrder ( ) const

Returns true if the order of the training dataset should be randomized at each epoch of training. Randomizing the order of the training dataset stops a learning algorithm from focusing too much on the first few examples in the dataset.

Returns
returns true if the order of the training dataset should be randomized, false otherwise
Float MLBase::getRMSTrainingError ( ) const

Gets the root mean squared error on the training data during the training phase.

Returns
returns the RMS error (on the training data during the training phase)

Definition at line 266 of file MLBase.cpp.

Float MLBase::getRMSValidationError ( ) const

Gets the root mean squared error on the validation data during the training phase, this will be zero if no validation set was used.

Returns
returns the RMS error (on the validation data during the training phase)

Definition at line 278 of file MLBase.cpp.

bool MLBase::getScalingEnabled ( ) const

Gets if the scaling has been enabled.

Returns
returns true if scaling is enabled, false otherwise

Definition at line 300 of file MLBase.cpp.

bool MLBase::getTestingLoggingEnabled ( ) const

Gets the logging state for the testing log, note this returns the logging state for this specific instance of the training log, not the global TestingLog state.

Returns
returns true if logging is enabled, false otherwise

Definition at line 316 of file MLBase.cpp.

Float MLBase::getTotalSquaredTrainingError ( ) const

Gets the total squared error on the training data during the training phase.

Returns
returns the total squared error (on the training data during the training phase)

Definition at line 274 of file MLBase.cpp.

bool MLBase::getTrained ( ) const

Gets if the model for the derived class has been succesfully trained.

Returns
returns true if the model for the derived class has been succesfully trained, false otherwise

Definition at line 294 of file MLBase.cpp.

bool MLBase::getTrainingLoggingEnabled ( ) const

Gets the logging state for the training log, note this returns the logging state for this specific instance of the training log, not the global TrainingLog state.

Returns
returns true if logging is enabled, false otherwise

Definition at line 312 of file MLBase.cpp.

Vector< TrainingResult > MLBase::getTrainingResults ( ) const

Gets the training results from the last training phase. Each element in the vector represents the training results from 1 training iteration.

Returns
returns a vector of TrainingResult instances containing the training results from the most recent training phase

Definition at line 431 of file MLBase.cpp.

MLBase::BaseType MLBase::getType ( ) const

Gets the current ML base type.

Returns
returns an enum representing the current ML base type, this will be one of the BaseType enumerations

Definition at line 227 of file MLBase.cpp.

bool MLBase::getUseValidationSet ( ) const

Returns true if a validation set should be used for training. If true, then the training dataset will be partitioned into a smaller training dataset and a validation set.

The size of the partition is controlled by the validationSetSize parameter, for example, if the validationSetSize parameter is 20 then 20% of the training data will be used for a validation set leaving 80% of the original data to train the model.

Returns
returns true if a validation set should be used for training, false otherwise

Definition at line 310 of file MLBase.cpp.

Float MLBase::getValidationSetAccuracy ( ) const

Gets the accuracy of the validation set on the trained model, only valid if the model was trained with useValidationSet=true.

Returns
returns the accuracy of validation set on the trained model

Definition at line 282 of file MLBase.cpp.

VectorFloat MLBase::getValidationSetPrecision ( ) const

Gets the precision of the validation set on the trained model, only valid if the model was trained with useValidationSet=true.

Returns
returns the precision of the validation set on the trained model

Definition at line 286 of file MLBase.cpp.

VectorFloat MLBase::getValidationSetRecall ( ) const

Gets the recall of the validation set on the trained model, only valid if the model was trained with useValidationSet=true.

Returns
returns the recall of the validation set on the trained model

Definition at line 290 of file MLBase.cpp.

UINT MLBase::getValidationSetSize ( ) const

Gets the size (as a percentage) of the validation set (if one should be used). If this value returned 20 this would mean that 20% of the training data would be set aside to create a validation set and the other 80% would be used to actually train the regression model. This will only happen if the useValidationSet parameter is set to true, otherwise 100% of the training data will be used to train the regression model.

Returns
returns the size of the validation set

Definition at line 258 of file MLBase.cpp.

MLBase::GRT_DEPRECATED_MSG ( "saveModelToFile(std::string filename) is  deprecated,
use save(const std::string &filename) instead"  ,
virtual bool saveModelToFile(const std::string &filename)  const 
)
Deprecated:
use save(std::string filename) instead
Parameters
thename of the file to save the model to
Returns
returns true if the model was saved successfully, false otherwise
MLBase::GRT_DEPRECATED_MSG ( "saveModelToFile(std::fstream &file) is  deprecated,
use save(std::fstream &file) instead"  ,
virtual bool saveModelToFile(std::fstream &file)  const 
)
Deprecated:
use save(std::fstream &file) instead
Parameters
filea reference to the file the model will be saved to
Returns
returns true if the model was saved successfully, false otherwise
MLBase::GRT_DEPRECATED_MSG ( "loadModelFromFile(std::string filename) is  deprecated,
use load(const std::string &filename) instead"  ,
virtual bool   loadModelFromFileconst std::string &filename 
)
Deprecated:
use load(std::string filename) instead
Parameters
filenamethe name of the file to load the model from
Returns
returns true if the model was loaded successfully, false otherwise
MLBase::GRT_DEPRECATED_MSG ( "loadModelFromFile(std::fstream &file) is  deprecated,
use load(std::fstream &file) instead"  ,
virtual bool   loadModelFromFilestd::fstream &file 
)
Deprecated:
use load(std::fstream &file) instead
Parameters
filea reference to the file the model will be loaded from
Returns
returns true if the model was loaded successfully, false otherwise
MLBase::GRT_DEPRECATED_MSG ( "getRootMeanSquaredTrainingError() is  deprecated,
use getRMSTrainingError() instead"  ,
Float getRootMeanSquaredTrainingError()  const 
)
Deprecated:
use getRMSTrainingError() instead Gets the root mean squared error on the training data during the training phase.
Returns
returns the RMS error (on the training data during the training phase)
MLBase::GRT_DEPRECATED_MSG ( "getModelTrained() is  deprecated,
use getTrained() instead"  ,
bool getModelTrained()  const 
)
Deprecated:
getTrained() function instead This function is now depreciated. You should use the getTrained() function instead.
Returns
returns true if the model for the derived class has been succesfully trained, false otherwise
bool MLBase::load ( const std::string &  filename)
virtual

This saves the model to a file.

Parameters
filenamethe name of the file to save the model to
Returns
returns true if the model was saved successfully, false otherwise

Reimplemented in GestureRecognitionPipeline.

Examples:
ClusteringModulesExamples/GaussianMixtureModelsExample/GaussianMixtureModelsExample.cpp.

Definition at line 190 of file MLBase.cpp.

bool MLBase::loadBaseSettingsFromFile ( std::fstream &  file)
protected

Loads the core base settings from a file.

Returns
returns true if the base settings were loaded, false otherwise

Definition at line 458 of file MLBase.cpp.

bool MLBase::map ( VectorFloat  inputVector)
virtual

This is the main mapping interface for all the GRT machine learning algorithms. By defaut it will call the map_ function, unless it is overwritten by the derived class.

Parameters
inputVectorthe input vector for mapping/regression
Returns
returns true if the mapping was completed succesfully, false otherwise (the base class always returns false)

Definition at line 143 of file MLBase.cpp.

bool MLBase::map_ ( VectorFloat inputVector)
virtual

This is the main mapping interface by reference for all the GRT machine learning algorithms. This should be overwritten by the derived class.

Parameters
inputVectora reference to the input vector for mapping/regression
Returns
returns true if the mapping was completed succesfully, false otherwise (the base class always returns false)

Reimplemented in SelfOrganizingMap.

Definition at line 145 of file MLBase.cpp.

bool MLBase::notifyTestResultsObservers ( const TestInstanceResult data)

Notifies all observers that have subscribed to the test results observer manager.

Parameters
datastores the test results data for the current update
Returns
returns true if all the observers were notified, false otherwise

Definition at line 419 of file MLBase.cpp.

bool MLBase::notifyTrainingResultsObservers ( const TrainingResult data)

Notifies all observers that have subscribed to the training results observer manager.

Parameters
datastores the training results data for the current update
Returns
returns true if all the observers were notified, false otherwise

Definition at line 415 of file MLBase.cpp.

bool MLBase::predict ( MatrixFloat  inputMatrix)
virtual

This is the prediction interface for time series data. By defaut it will call the predict_ function, unless it is overwritten by the derived class.

Parameters
inputMatrixthe new input matrix for prediction
Returns
returns true if the prediction was completed succesfully, false otherwise (the base class always returns false)

Definition at line 139 of file MLBase.cpp.

bool MLBase::predict_ ( VectorFloat inputVector)
virtual

This is the main prediction interface for all the GRT machine learning algorithms. This should be overwritten by the derived class.

Parameters
inputVectora reference to the input vector for prediction
Returns
returns true if the prediction was completed succesfully, false otherwise (the base class always returns false)

Reimplemented in GestureRecognitionPipeline, DTW, KMeans, AdaBoost, SVM, HMM, KNN, GaussianMixtureModels, RandomForests, FiniteStateMachine, DecisionTree, ANBC, MLP, GMM, MultidimensionalRegression, ClusterTree, Softmax, SwipeDetector, RegressionTree, BAG, MinDist, LogisticRegression, LinearRegression, ParticleClassifier, RegressionTreeNode, DecisionTreeClusterNode, DecisionTreeThresholdNode, ClusterTreeNode, DecisionTreeTripleFeatureNode, BernoulliRBM, Node, ContinuousHiddenMarkovModel, and MovementDetector.

Definition at line 137 of file MLBase.cpp.

bool MLBase::predict_ ( MatrixFloat inputMatrix)
virtual

This is the prediction interface for time series data. This should be overwritten by the derived class.

Parameters
inputMatrixa reference to the new input matrix for prediction
Returns
returns true if the prediction was completed succesfully, false otherwise (the base class always returns false)

Reimplemented in GestureRecognitionPipeline, DTW, HMM, and ContinuousHiddenMarkovModel.

Definition at line 141 of file MLBase.cpp.

bool MLBase::print ( ) const
virtual

This is the main print interface for all the GRT machine learning algorithms. This should be overwritten by the derived class. It will print the model and settings to the display log.

Returns
returns true if the model was printed succesfully, false otherwise (the base class always returns true)

Reimplemented in HMM, FiniteStateMachine, ClusterTreeNode, RegressionTreeNode, RandomForests, BernoulliRBM, MLP, ClusterTree, RegressionTree, Node, DiscreteHiddenMarkovModel, ContinuousHiddenMarkovModel, DecisionTreeClusterNode, DecisionTreeThresholdNode, DecisionTreeTripleFeatureNode, and Tree.

Examples:
ClassificationModulesExamples/DecisionTreeExample/DecisionTreeExample.cpp.

Definition at line 165 of file MLBase.cpp.

bool MLBase::registerTestResultsObserver ( Observer< TestInstanceResult > &  observer)

Registers the observer with the test result observer manager. The observer will then be notified when any new test result is computed.

Parameters
observerthe observer you want to register with the learning algorithm
Returns
returns true the observer was added, false otherwise

Definition at line 395 of file MLBase.cpp.

bool MLBase::registerTrainingResultsObserver ( Observer< TrainingResult > &  observer)

Registers the observer with the training result observer manager. The observer will then be notified when any new training result is computed.

Parameters
observerthe observer you want to register with the learning algorithm
Returns
returns true the observer was added, false otherwise

Definition at line 391 of file MLBase.cpp.

bool MLBase::removeAllTestObservers ( )

Removes all observers from the training result observer manager.

Returns
returns true if all the observers were removed, false otherwise

Definition at line 411 of file MLBase.cpp.

bool MLBase::removeAllTrainingObservers ( )

Removes all observers from the training result observer manager.

Returns
returns true if all the observers were removed, false otherwise

Definition at line 407 of file MLBase.cpp.

bool MLBase::removeTestResultsObserver ( const Observer< TestInstanceResult > &  observer)

Removes the observer from the test result observer manager.

Parameters
observerthe observer you want to remove from the learning algorithm
Returns
returns true if the observer was removed, false otherwise

Definition at line 403 of file MLBase.cpp.

bool MLBase::removeTrainingResultsObserver ( const Observer< TrainingResult > &  observer)

Removes the observer from the training result observer manager.

Parameters
observerthe observer you want to remove from the learning algorithm
Returns
returns true if the observer was removed, false otherwise

Definition at line 399 of file MLBase.cpp.

bool MLBase::reset ( )
virtual

This is the main reset interface for all the GRT machine learning algorithms. It should be used to reset the model (i.e. set all values back to default settings). If you want to completely clear the model (i.e. clear any learned weights or values) then you should use the clear function.

Returns
returns true if the derived class was reset succesfully, false otherwise (the base class always returns true)

Reimplemented in GestureRecognitionPipeline, SelfOrganizingMap, DTW, HierarchicalClustering, ClassLabelTimeoutFilter, FFT, HMM, FiniteStateMachine, ParticleClassifier, SwipeDetector, ANBC, ZeroCrossingCounter, BAG, ClassLabelFilter, RBMQuantizer, FIRFilter, KMeansQuantizer, MovementTrajectoryFeatures, SOMQuantizer, TimeDomainFeatures, Derivative, LowPassFilter, HighPassFilter, FFTFeatures, Clusterer, SavitzkyGolayFilter, KMeansFeatures, MovementIndex, BernoulliRBM, ClassLabelChangeFilter, DeadZone, DoubleMovingAverageFilter, MedianFilter, MovingAverageFilter, EnvelopeExtractor, LeakyIntegrator, RMSFilter, WeightedAverageFilter, TimeseriesBuffer, Context, KMeans, PreProcessing, GaussianMixtureModels, Classifier, Regressifier, DiscreteHiddenMarkovModel, Gate, ContinuousHiddenMarkovModel, and MovementDetector.

Definition at line 147 of file MLBase.cpp.

bool MLBase::save ( const std::string &  filename) const
virtual

This saves the model to a file.

Parameters
filenamethe name of the file to save the model to
Returns
returns true if the model was saved successfully, false otherwise

Reimplemented in GestureRecognitionPipeline.

Examples:
ClusteringModulesExamples/GaussianMixtureModelsExample/GaussianMixtureModelsExample.cpp.

Definition at line 167 of file MLBase.cpp.

bool MLBase::saveBaseSettingsToFile ( std::fstream &  file) const
protected

Saves the core base settings to a file.

Returns
returns true if the base settings were saved, false otherwise

Definition at line 435 of file MLBase.cpp.

bool MLBase::setBatchSize ( const UINT  batchSize)

Sets the batch size used during the training phase.

Parameters
batchSizethe batch size
Returns
returns true if the value was updated successfully, false otherwise

Definition at line 334 of file MLBase.cpp.

bool MLBase::setLearningRate ( const Float  learningRate)

Sets the learningRate. This is used to update the weights at each step of learning algorithms such as stochastic gradient descent. The learningRate value must be greater than zero.

Parameters
learningRatethe learningRate value used during the training phase, must be greater than zero
Returns
returns true if the value was updated successfully, false otherwise
Examples:
RegressionModulesExamples/MLPRegressionExample/MLPRegressionExample.cpp.

Definition at line 353 of file MLBase.cpp.

bool MLBase::setMaxNumEpochs ( const UINT  maxNumEpochs)

Sets the maximum number of epochs (a complete iteration of all training samples) that can be run during the training phase. The maxNumIterations value must be greater than zero.

Parameters
maxNumIterationsthe maximum number of iterations value, must be greater than zero
Returns
returns true if the value was updated successfully, false otherwise
Examples:
ClusteringModulesExamples/GaussianMixtureModelsExample/GaussianMixtureModelsExample.cpp, ClusteringModulesExamples/KMeansExample/KMeansExample.cpp, and RegressionModulesExamples/MLPRegressionExample/MLPRegressionExample.cpp.

Definition at line 320 of file MLBase.cpp.

bool MLBase::setMinChange ( const Float  minChange)

Sets the minimum change that must be achieved between two training epochs for the training to continue. The minChange value must be greater than zero.

Parameters
minChangethe minimum change value, must be greater than zero
Returns
returns true if the value was updated successfully, false otherwise
Examples:
ClusteringModulesExamples/GaussianMixtureModelsExample/GaussianMixtureModelsExample.cpp, ClusteringModulesExamples/KMeansExample/KMeansExample.cpp, and RegressionModulesExamples/MLPRegressionExample/MLPRegressionExample.cpp.

Definition at line 344 of file MLBase.cpp.

bool MLBase::setMinNumEpochs ( const UINT  minNumEpochs)

Sets the minimum number of epochs (a complete iteration of all training samples) that can elapse with no change between two training epochs.

Parameters
minNumEpochsthe minimum number of epochs that can elapse with no change between two training epochs
Returns
returns true if the value was updated successfully, false otherwise
Examples:
ClusteringModulesExamples/GaussianMixtureModelsExample/GaussianMixtureModelsExample.cpp, and ClusteringModulesExamples/KMeansExample/KMeansExample.cpp.

Definition at line 329 of file MLBase.cpp.

bool MLBase::setNumRestarts ( const UINT  numRestarts)

Sets the number of times a learning algorithm can restart during training. This is used to restart the training for algorithms that can get stuck if they start with bad random values.

Parameters
numRestartsnumber of times a learning algorithm can restart during training
Returns
returns true if the value was updated successfully, false otherwise
Examples:
RegressionModulesExamples/MLPRegressionExample/MLPRegressionExample.cpp.

Definition at line 339 of file MLBase.cpp.

bool MLBase::setRandomiseTrainingOrder ( const bool  randomiseTrainingOrder)

Sets if the order of the training dataset should be randomized at each epoch of training. Randomizing the order of the training dataset stops a learning algorithm from focusing too much on the first few examples in the dataset.

Parameters
randomiseTrainingOrderif true then the order in which training samples are supplied to a learning algorithm will be randomised
Returns
returns true if the parameter was updated, false otherwise
Examples:
RegressionModulesExamples/MLPRegressionExample/MLPRegressionExample.cpp.

Definition at line 378 of file MLBase.cpp.

bool MLBase::setTestingLoggingEnabled ( const bool  loggingEnabled)

Sets if testing logging is enabled/disabled for this specific ML instance. If you want to enable/disable testing logging globally, then you should use the TestingLog::enableLogging( bool ) function.

Parameters
loggingEnabledif true then training logging will be enabled, if false then training logging will be disabled
Returns
returns true if the parameter was updated, false otherwise

Definition at line 387 of file MLBase.cpp.

bool MLBase::setTrainingLoggingEnabled ( const bool  loggingEnabled)

Sets if training logging is enabled/disabled for this specific ML instance. If you want to enable/disable training logging globally, then you should use the TrainingLog::enableLogging( bool ) function.

Parameters
loggingEnabledif true then training logging will be enabled, if false then training logging will be disabled
Returns
returns true if the parameter was updated, false otherwise

Definition at line 383 of file MLBase.cpp.

bool MLBase::setUseValidationSet ( const bool  useValidationSet)

Sets the size of the validation set used by some learning algorithms for training. This value represents the percentage of the main dataset that will be used for training. For example, if the validationSetSize parameter is 20 then 20% of the training data will be used for a validation set leaving 80% of the original data to train the model.

Parameters
validationSetSizethe new validation set size (as a percentage)
Returns
returns true if the validationSetSize parameter was updated, false otherwise
Examples:
RegressionModulesExamples/MLPRegressionExample/MLPRegressionExample.cpp.

Definition at line 373 of file MLBase.cpp.

bool MLBase::setValidationSetSize ( const UINT  validationSetSize)

Sets the size of the validation set used by some learning algorithms for training. This value represents the percentage of the main dataset that will be used for training. For example, if the validationSetSize parameter is 20 then 20% of the training data will be used for a validation set leaving 80% of the original data to train the model.

Parameters
validationSetSizethe new validation set size (as a percentage)
Returns
returns true if the validationSetSize parameter was updated, false otherwise
Examples:
RegressionModulesExamples/MLPRegressionExample/MLPRegressionExample.cpp.

Definition at line 361 of file MLBase.cpp.

bool MLBase::train ( RegressionData  trainingData)
virtual

This is the main training interface for regression data. By default it will call the train_ function, unless it is overwritten by the derived class.

Parameters
trainingDatathe training data that will be used to train a new regression model
Returns
returns true if a new regression model was trained, false otherwise

Definition at line 111 of file MLBase.cpp.

bool MLBase::train ( RegressionData  trainingData,
RegressionData  validationData 
)
virtual

This is the main training interface for training a regression model using a training and validation dataset. This should be overwritten by the derived class. By default it will call the train_ function, unless it is overwritten by the derived class.

Parameters
trainingDatathe training data that will be used to train a new regression model
validationDatathe validation data that will be used to validate the regression model
Returns
returns true if a new regression model was trained, false otherwise

Definition at line 115 of file MLBase.cpp.

bool MLBase::train ( TimeSeriesClassificationData  trainingData)
virtual

This is the main training interface for TimeSeriesClassificationData. By default it will call the train_ function, unless it is overwritten by the derived class.

Parameters
trainingDatathe training data that will be used to train the ML model
Returns
returns true if the classifier was successfully trained, false otherwise

Definition at line 119 of file MLBase.cpp.

bool MLBase::train ( ClassificationDataStream  trainingData)
virtual

This is the main training interface for ClassificationDataStream. By default it will call the train_ function, unless it is overwritten by the derived class.

Parameters
trainingDatathe training data that will be used to train the ML model
Returns
returns true if the classifier was successfully trained, false otherwise

Definition at line 123 of file MLBase.cpp.

bool MLBase::train ( UnlabelledData  trainingData)
virtual

This is the main training interface for UnlabelledData. By default it will call the train_ function, unless it is overwritten by the derived class.

Parameters
trainingDatathe training data that will be used to train the ML model
Returns
returns true if the classifier was successfully trained, false otherwise

Definition at line 127 of file MLBase.cpp.

bool MLBase::train ( MatrixFloat  data)
virtual

This is the main training interface for MatrixFloat data. By default it will call the train_ function, unless it is overwritten by the derived class.

Parameters
trainingDatathe training data that will be used to train the ML model
Returns
returns true if the classifier was successfully trained, false otherwise

Definition at line 131 of file MLBase.cpp.

bool MLBase::train_ ( ClassificationData trainingData)
virtual

This is the main training interface for referenced ClassificationData. This should be overwritten by the derived class.

Parameters
trainingDataa reference to the training data that will be used to train the ML model
Returns
returns true if the classifier was successfully trained, false otherwise

Reimplemented in SelfOrganizingMap, HierarchicalClustering, KMeansQuantizer, RBMQuantizer, SOMQuantizer, GestureRecognitionPipeline, KMeansFeatures, KMeans, AdaBoost, SVM, KNN, RandomForests, GaussianMixtureModels, DecisionTree, ANBC, GMM, Softmax, SwipeDetector, BAG, MinDist, MLP, Clusterer, and FiniteStateMachine.

Definition at line 109 of file MLBase.cpp.

bool MLBase::train_ ( RegressionData trainingData)
virtual

This is the main training interface for all the regression algorithms. This should be overwritten by the derived class.

Parameters
trainingDatathe training data that will be used to train a new regression model
Returns
returns true if a new regression model was trained, false otherwise

Reimplemented in GestureRecognitionPipeline, MLP, MultidimensionalRegression, RegressionTree, LogisticRegression, and LinearRegression.

Definition at line 113 of file MLBase.cpp.

bool MLBase::train_ ( RegressionData trainingData,
RegressionData validationData 
)
virtual

This is the main training interface for training a regression model using a training and validation dataset. This should be overwritten by the derived class.

Parameters
trainingDatathe training data that will be used to train a new regression model
validationDatathe validation data that will be used to validate the regression model
Returns
returns true if a new regression model was trained, false otherwise

Reimplemented in GestureRecognitionPipeline.

Definition at line 117 of file MLBase.cpp.

bool MLBase::train_ ( TimeSeriesClassificationData trainingData)
virtual

This is the main training interface for referenced TimeSeriesClassificationData. This should be overwritten by the derived class.

Parameters
trainingDataa reference to the training data that will be used to train the ML model
Returns
returns true if the classifier was successfully trained, false otherwise

Reimplemented in GestureRecognitionPipeline, DTW, KMeansQuantizer, RBMQuantizer, SOMQuantizer, KMeansFeatures, HMM, FiniteStateMachine, and ParticleClassifier.

Definition at line 121 of file MLBase.cpp.

bool MLBase::train_ ( ClassificationDataStream trainingData)
virtual

This is the main training interface for referenced ClassificationDataStream. This should be overwritten by the derived class.

Parameters
trainingDataa reference to the training data that will be used to train the ML model
Returns
returns true if the classifier was successfully trained, false otherwise

Reimplemented in GestureRecognitionPipeline, KMeansQuantizer, RBMQuantizer, SOMQuantizer, KMeansFeatures, and FiniteStateMachine.

Definition at line 125 of file MLBase.cpp.

bool MLBase::train_ ( UnlabelledData trainingData)
virtual

This is the main training interface for referenced UnlabelledData. This should be overwritten by the derived class.

Parameters
trainingDataa reference to the training data that will be used to train the ML model
Returns
returns true if the classifier was successfully trained, false otherwise

Reimplemented in SelfOrganizingMap, GestureRecognitionPipeline, HierarchicalClustering, KMeansQuantizer, RBMQuantizer, SOMQuantizer, KMeansFeatures, KMeans, GaussianMixtureModels, and Clusterer.

Definition at line 129 of file MLBase.cpp.

bool MLBase::train_ ( MatrixFloat data)
virtual

This is the main training interface for referenced MatrixFloat data. This should be overwritten by the derived class.

Parameters
trainingDataa reference to the training data that will be used to train the ML model
Returns
returns true if the classifier was successfully trained, false otherwise

Reimplemented in SelfOrganizingMap, HierarchicalClustering, KMeansQuantizer, RBMQuantizer, SOMQuantizer, KMeansFeatures, KMeans, GaussianMixtureModels, ClusterTree, BernoulliRBM, and Clusterer.

Definition at line 133 of file MLBase.cpp.


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