GestureRecognitionToolkit  Version: 0.2.0
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
MLBase Class Reference
Inheritance diagram for MLBase:
GRTBase Observer< TrainingResult > Observer< TestInstanceResult > BernoulliRBM Classifier Clusterer Context ContinuousHiddenMarkovModel DiscreteHiddenMarkovModel FeatureExtraction GridSearch< T > LinearLeastSquares MeanShift MovementDetector PostProcessing PreProcessing PrincipalComponentAnalysis Regressifier

Public Types

enum  BaseTypes { BASE_TYPE_NOT_SET =0, CLASSIFIER, REGRESSIFIER, CLUSTERER }
 

Public Member Functions

 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_ (RegressionData &trainingData)
 
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(std::string filename) instead", virtual bool saveModelToFile(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(std::string filename) instead", virtual bool loadModelFromFile(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
 
Float scale (const Float &x, const Float &minSource, const Float &maxSource, const Float &minTarget, const Float &maxTarget, const bool constrain=false)
 
virtual std::string getModelAsString () const
 
DataType getInputType () const
 
DataType getOutputType () 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
 
Float getMinChange () const
 
Float getLearningRate () const
 
Float getRootMeanSquaredTrainingError () const
 
Float getTotalSquaredTrainingError () const
 
Float getValidationSetAccuracy () const
 
VectorFloat getValidationSetPrecision () const
 
VectorFloat getValidationSetRecall () 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 (const bool useScaling)
 
bool setMaxNumEpochs (const UINT maxNumEpochs)
 
bool setMinNumEpochs (const UINT minNumEpochs)
 
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 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< TrainingResult > getTrainingResults () const
 
- Public Member Functions inherited from GRTBase
 GRTBase (void)
 
virtual ~GRTBase (void)
 
bool copyGRTBaseVariables (const GRTBase *GRTBase)
 
std::string getClassType () 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)
 
GRTBasegetGRTBasePointer ()
 
const GRTBasegetGRTBasePointer () 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 Member Functions inherited from GRTBase
Float SQR (const Float &x) const
 

Protected Attributes

bool trained
 
bool useScaling
 
DataType inputType
 
DataType outputType
 
UINT baseType
 
UINT numInputDimensions
 
UINT numOutputDimensions
 
UINT numTrainingIterationsToConverge
 
UINT minNumEpochs
 
UINT maxNumEpochs
 
UINT validationSetSize
 
Float learningRate
 
Float minChange
 
Float rootMeanSquaredTrainingError
 
Float totalSquaredTrainingError
 
Float validationSetAccuracy
 
bool useValidationSet
 
bool randomiseTrainingOrder
 
VectorFloat validationSetPrecision
 
VectorFloat validationSetRecall
 
Random random
 
std::vector< TrainingResult > trainingResults
 
TrainingResultsObserverManager trainingResultsObserverManager
 
TestResultsObserverManager testResultsObserverManager
 
- Protected Attributes inherited from GRTBase
std::string classType
 
DebugLog debugLog
 
ErrorLog errorLog
 
InfoLog infoLog
 
TrainingLog trainingLog
 
TestingLog testingLog
 
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

Definition at line 70 of file MLBase.h.

Constructor & Destructor Documentation

GRT_BEGIN_NAMESPACE MLBase::MLBase ( void  )

Default MLBase Constructor

Definition at line 26 of file MLBase.cpp.

MLBase::~MLBase ( void  )
virtual

Default MLBase Destructor

Definition at line 46 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 SelfOrganizingMap, HierarchicalClustering, DTW, HMM, FFT, FiniteStateMachine, AdaBoost, SVM, ANBC, KNN, RandomForests, DecisionTree, BAG, GMM, RBMQuantizer, ParticleClassifier, KMeansQuantizer, SOMQuantizer, FIRFilter, ClusterTree, RegressionTree, MinDist, Softmax, MLP, SwipeDetector, Clusterer, BernoulliRBM, FeatureExtraction, KMeans, PreProcessing, GaussianMixtureModels, Classifier, Regressifier, ContinuousHiddenMarkovModel, and MovementDetector.

Definition at line 127 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 50 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

Definition at line 271 of file MLBase.cpp.

UINT MLBase::getBaseType ( ) const

Gets the current ML base type.

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

Definition at line 208 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 200 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 265 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 269 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 267 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 235 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 227 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 223 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 363 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 367 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.

Definition at line 190 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

Definition at line 192 of file MLBase.cpp.

bool MLBase::getModelTrained ( ) const

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

Definition at line 261 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 212 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 210 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 214 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

Definition at line 216 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 204 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::getRootMeanSquaredTrainingError ( ) 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 239 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 263 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 243 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 259 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 371 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
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 247 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 251 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 255 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 231 of file MLBase.cpp.

MLBase::GRT_DEPRECATED_MSG ( "saveModelToFile(std::string filename) is  deprecated,
use save(std::string filename) instead"  ,
virtual bool saveModelToFile(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(std::string filename) instead"  ,
virtual bool   loadModelFromFilestd::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
bool MLBase::load ( const std::string  filename)
virtual

This saves the model to a file, it calls the loadModelFromFile(std::string filename) function unless it is overwritten by the derived class.

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

Definition at line 167 of file MLBase.cpp.

bool MLBase::load ( std::fstream &  file)
virtual

This loads a trained model from a file. This function should be overwritten by the derived class.

Parameters
filea reference to the file the model will be loaded from
Returns
returns true if the model was loaded successfully, false otherwise

Reimplemented in DTW, HMM, FiniteStateMachine, RandomForests, AdaBoost, DecisionTree, SVM, ANBC, KNN, RegressionTree, BAG, MLP, SwipeDetector, RBMQuantizer, GMM, FIRFilter, PrincipalComponentAnalysis, MinDist, Softmax, Derivative, LowPassFilter, BernoulliRBM, HighPassFilter, SavitzkyGolayFilter, DeadZone, DoubleMovingAverageFilter, MedianFilter, MovingAverageFilter, MultidimensionalRegression, WeightedAverageFilter, LeakyIntegrator, LinearRegression, LogisticRegression, ParticleClassifier, DiscreteHiddenMarkovModel, ContinuousHiddenMarkovModel, and MovementDetector.

Definition at line 182 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 398 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 121 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 123 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 359 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 355 of file MLBase.cpp.

bool MLBase::predict ( VectorFloat  inputVector)
virtual

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

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

Reimplemented in LDA.

Definition at line 113 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 117 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 DTW, KMeans, SVM, AdaBoost, HMM, GaussianMixtureModels, KNN, RandomForests, FiniteStateMachine, DecisionTree, ANBC, GMM, ClusterTree, RegressionTree, MLP, BAG, MinDist, Softmax, SwipeDetector, MultidimensionalRegression, LinearRegression, LogisticRegression, ParticleClassifier, BernoulliRBM, ContinuousHiddenMarkovModel, and MovementDetector.

Definition at line 115 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 DTW, HMM, and ContinuousHiddenMarkovModel.

Definition at line 119 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, RandomForests, BernoulliRBM, ClusterTree, RegressionTree, MLP, DiscreteHiddenMarkovModel, and ContinuousHiddenMarkovModel.

Definition at line 141 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 335 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 331 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 351 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 347 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 343 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 339 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 SelfOrganizingMap, HierarchicalClustering, DTW, ClassLabelTimeoutFilter, FFT, HMM, FiniteStateMachine, ParticleClassifier, ANBC, SwipeDetector, ZeroCrossingCounter, BAG, ClassLabelFilter, RBMQuantizer, KMeansQuantizer, SOMQuantizer, TimeDomainFeatures, Derivative, FIRFilter, LowPassFilter, MovementTrajectoryFeatures, HighPassFilter, FFTFeatures, SavitzkyGolayFilter, Clusterer, KMeansFeatures, MovementIndex, EnvelopeExtractor, DeadZone, BernoulliRBM, ClassLabelChangeFilter, DoubleMovingAverageFilter, MedianFilter, MovingAverageFilter, WeightedAverageFilter, TimeseriesBuffer, LeakyIntegrator, FeatureExtraction, Context, KMeans, PostProcessing, GaussianMixtureModels, PreProcessing, Classifier, Regressifier, DiscreteHiddenMarkovModel, ContinuousHiddenMarkovModel, MovementDetector, and Gate.

Definition at line 125 of file MLBase.cpp.

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

This saves the model to a file, it calls the saveModelToFile(std::string filename) function unless it is overwritten by the derived class.

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

Definition at line 143 of file MLBase.cpp.

bool MLBase::save ( std::fstream &  file) const
virtual

This saves the trained model to a file. This function should be overwritten by the derived class.

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

Reimplemented in DTW, HMM, FiniteStateMachine, RandomForests, AdaBoost, DecisionTree, SVM, ANBC, KNN, RegressionTree, BAG, MLP, SwipeDetector, RBMQuantizer, GMM, PrincipalComponentAnalysis, FIRFilter, MinDist, Softmax, BernoulliRBM, Derivative, LowPassFilter, HighPassFilter, SavitzkyGolayFilter, DeadZone, DoubleMovingAverageFilter, MedianFilter, MovingAverageFilter, MultidimensionalRegression, WeightedAverageFilter, LeakyIntegrator, LinearRegression, LogisticRegression, ParticleClassifier, DiscreteHiddenMarkovModel, ContinuousHiddenMarkovModel, and MovementDetector.

Definition at line 159 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 375 of file MLBase.cpp.

Float MLBase::scale ( const Float &  x,
const Float &  minSource,
const Float &  maxSource,
const Float &  minTarget,
const Float &  maxTarget,
const bool  constrain = false 
)
inline

Scales the input value x (which should be in the range [minSource maxSource]) to a value in the new target range of [minTarget maxTarget].

Parameters
xthe value that should be scaled
minSourcethe minimum range that x originates from
maxSourcethe maximum range that x originates from
minTargetthe minimum range that x should be scaled to
maxTargetthe maximum range that x should be scaled to
constrainsets if the scaled value should be constrained to the target range
Returns
returns a new value that has been scaled based on the input parameters

Definition at line 353 of file MLBase.h.

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

Definition at line 296 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

Definition at line 273 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

Definition at line 287 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

Definition at line 282 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

Definition at line 321 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 326 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

Definition at line 316 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

Definition at line 304 of file MLBase.cpp.

bool MLBase::train ( ClassificationData  trainingData)
virtual

This is the main training interface for ClassificationData. 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

Reimplemented in LDA, and HMM.

Definition at line 89 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 93 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 97 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 101 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 105 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 109 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, SOMQuantizer, KMeansFeatures, RBMQuantizer, KMeansQuantizer, KMeans, SVM, AdaBoost, KNN, RandomForests, GaussianMixtureModels, DecisionTree, ANBC, GMM, BAG, MinDist, Softmax, SwipeDetector, FiniteStateMachine, MLP, and Clusterer.

Definition at line 91 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 RegressionTree, MLP, MultidimensionalRegression, LinearRegression, and LogisticRegression.

Definition at line 95 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 SOMQuantizer, DTW, KMeansFeatures, RBMQuantizer, KMeansQuantizer, HMM, FiniteStateMachine, and ParticleClassifier.

Definition at line 99 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 SOMQuantizer, KMeansFeatures, RBMQuantizer, KMeansQuantizer, and FiniteStateMachine.

Definition at line 103 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, HierarchicalClustering, SOMQuantizer, KMeansFeatures, RBMQuantizer, KMeansQuantizer, KMeans, GaussianMixtureModels, and Clusterer.

Definition at line 107 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, SOMQuantizer, KMeansFeatures, RBMQuantizer, KMeansQuantizer, KMeans, GaussianMixtureModels, ClusterTree, BernoulliRBM, and Clusterer.

Definition at line 111 of file MLBase.cpp.


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