GestureRecognitionToolkit  Version: 0.1.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 saveModelToFile (std::string filename) const
 
virtual bool saveModelToFile (std::fstream &file) const
 
virtual bool loadModelFromFile (std::string filename)
 
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

GRT MIT License Copyright (c) <2012> <Nicholas Gillian, Media Lab, MIT>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition at line 25 of file MLBase.cpp.

MLBase::~MLBase ( void  )
virtual

Default MLBase Destructor

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

Definition at line 126 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 49 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 266 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 203 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 195 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 260 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 264 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 262 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 230 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 222 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 218 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 358 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 362 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 185 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 187 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 256 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 207 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 205 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 209 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 211 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 199 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 234 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 258 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 238 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 254 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 366 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 242 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 246 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 250 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 226 of file MLBase.cpp.

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 164 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 393 of file MLBase.cpp.

bool MLBase::loadModelFromFile ( std::string  filename)
virtual

This loads a trained model from a file, it calls the loadModelFromFile(fstream &file) function unless it is overwritten by the derived class.

Parameters
filenamethe name of the file to load the model from
Returns
returns true if the model was loaded successfully, false otherwise

Reimplemented in ClassLabelTimeoutFilter, FIRFilter, ClassLabelFilter, LowPassFilter, HighPassFilter, RBMQuantizer, Derivative, SOMQuantizer, ZeroCrossingCounter, SavitzkyGolayFilter, DeadZone, ClassLabelChangeFilter, DoubleMovingAverageFilter, MedianFilter, MovingAverageFilter, MovementTrajectoryFeatures, FFTFeatures, KMeansFeatures, MovementIndex, TimeseriesBuffer, PreProcessing, TimeDomainFeatures, and PostProcessing.

Definition at line 168 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 120 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 122 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 354 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 350 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 112 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 116 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, AdaBoost, HMM, SVM, 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 114 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 118 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 140 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 330 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 326 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 346 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 342 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 338 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 334 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, LowPassFilter, MovementTrajectoryFeatures, HighPassFilter, FFTFeatures, Derivative, FIRFilter, SavitzkyGolayFilter, Clusterer, KMeansFeatures, MovementIndex, DeadZone, BernoulliRBM, ClassLabelChangeFilter, DoubleMovingAverageFilter, MedianFilter, MovingAverageFilter, WeightedAverageFilter, TimeseriesBuffer, LeakyIntegrator, FeatureExtraction, TimeDomainFeatures, Context, KMeans, PostProcessing, GaussianMixtureModels, PreProcessing, Regressifier, Classifier, DiscreteHiddenMarkovModel, ContinuousHiddenMarkovModel, MovementDetector, and Gate.

Definition at line 124 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 142 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 370 of file MLBase.cpp.

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

This saves the trained model to a file, it calls the saveModelToFile(fstream &file) function unless it is overwritten by the derived class.

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

Reimplemented in ClassLabelTimeoutFilter, RBMQuantizer, SOMQuantizer, ZeroCrossingCounter, FIRFilter, ClassLabelFilter, LowPassFilter, HighPassFilter, MovementTrajectoryFeatures, Derivative, FFTFeatures, SavitzkyGolayFilter, KMeansFeatures, MovementIndex, DeadZone, ClassLabelChangeFilter, DoubleMovingAverageFilter, MedianFilter, MovingAverageFilter, TimeseriesBuffer, TimeDomainFeatures, PreProcessing, and PostProcessing.

Definition at line 146 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 339 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 291 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 268 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 282 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 277 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 316 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 321 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 311 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 299 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 88 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 92 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 96 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 100 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 104 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 108 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, RBMQuantizer, SOMQuantizer, KMeansFeatures, KMeansQuantizer, KMeans, AdaBoost, SVM, KNN, RandomForests, GaussianMixtureModels, DecisionTree, ANBC, GMM, BAG, MinDist, Softmax, SwipeDetector, FiniteStateMachine, MLP, and Clusterer.

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

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

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

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

Definition at line 110 of file MLBase.cpp.


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