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.
|
This is the main base class that all GRT machine learning algorithms should inherit from. More...
#include <MLBase.h>
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) |
MLBase * | getMLBasePointer () |
const MLBase * | getMLBasePointer () const |
Vector< TrainingResult > | getTrainingResults () 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) |
GRTBase * | getGRTBasePointer () |
const GRTBase * | getGRTBasePointer () 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< TrainingResult > | trainingResults |
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 () |
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.
GRT_BEGIN_NAMESPACE MLBase::MLBase | ( | const std::string & | id = "" , |
const BaseType | type = BASE_TYPE_NOT_SET |
||
) |
Default MLBase Constructor
id | the id of the inheriting class |
type | the type of the inheriting class (e.g., classifier, regressifier, etc.) |
Definition at line 26 of file MLBase.cpp.
|
virtual |
Default MLBase Destructor
Definition at line 58 of file MLBase.cpp.
|
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.
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.
mlBase | a pointer to a MLBase class from which the values will be copied to the instance that calls the function |
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.
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.
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.
Definition at line 298 of file MLBase.cpp.
DataType MLBase::getInputType | ( | ) | const |
Gets the expected input data type for the module
Definition at line 223 of file MLBase.cpp.
bool MLBase::getIsBaseTypeClassifier | ( | ) | const |
Gets if the derived class type is CLASSIFIER.
Definition at line 302 of file MLBase.cpp.
bool MLBase::getIsBaseTypeClusterer | ( | ) | const |
Gets if the derived class type is CLUSTERER.
Definition at line 306 of file MLBase.cpp.
bool MLBase::getIsBaseTypeRegressifier | ( | ) | const |
Gets if the derived class type is REGRESSIFIER.
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.
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.
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.
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.
Definition at line 242 of file MLBase.cpp.
MLBase * MLBase::getMLBasePointer | ( | ) |
This functions returns a 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.
Definition at line 427 of file MLBase.cpp.
|
virtual |
This function adds the current model to the formatted stream. This function should be overwritten by the derived class.
file | a reference to the stream the model will be added to |
Reimplemented in DecisionTree, Node, DecisionTreeClusterNode, DecisionTreeNode, DecisionTreeThresholdNode, DecisionTreeTripleFeatureNode, and Tree.
Definition at line 213 of file MLBase.cpp.
|
virtual |
Gets the current model and settings as a std::string.
Reimplemented in GestureRecognitionPipeline.
Definition at line 215 of file MLBase.cpp.
UINT MLBase::getNumInputDimensions | ( | ) | const |
Gets the number of input dimensions in trained model.
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.
Definition at line 229 of file MLBase.cpp.
UINT MLBase::getNumOutputDimensions | ( | ) | const |
Gets the number of output dimensions in trained model.
Definition at line 233 of file MLBase.cpp.
UINT MLBase::getNumRestarts | ( | ) | const |
Gets 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.
Definition at line 235 of file MLBase.cpp.
DataType MLBase::getOutputType | ( | ) | const |
Gets the expected output data type for the module
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.
Float MLBase::getRMSTrainingError | ( | ) | const |
Gets the root mean squared 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.
Definition at line 278 of file MLBase.cpp.
bool MLBase::getScalingEnabled | ( | ) | const |
Gets if the scaling has been enabled.
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.
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.
Definition at line 274 of file MLBase.cpp.
bool MLBase::getTrained | ( | ) | const |
Gets if the model for the derived class has been succesfully trained.
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.
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.
Definition at line 431 of file MLBase.cpp.
MLBase::BaseType MLBase::getType | ( | ) | const |
Gets the current ML base type.
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.
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.
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.
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.
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.
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 | ||
) |
the | name of the file to save the model to |
MLBase::GRT_DEPRECATED_MSG | ( | "saveModelToFile(std::fstream &file) is | deprecated, |
use save(std::fstream &file) instead" | , | ||
virtual bool saveModelToFile(std::fstream &file) | const | ||
) |
file | a reference to the file the model will be saved to |
MLBase::GRT_DEPRECATED_MSG | ( | "loadModelFromFile(std::string filename) is | deprecated, |
use load(const std::string &filename) instead" | , | ||
virtual bool | loadModelFromFileconst std::string &filename | ||
) |
filename | the name of the file to load the model from |
MLBase::GRT_DEPRECATED_MSG | ( | "loadModelFromFile(std::fstream &file) is | deprecated, |
use load(std::fstream &file) instead" | , | ||
virtual bool | loadModelFromFilestd::fstream &file | ||
) |
file | a reference to the file the model will be loaded from |
MLBase::GRT_DEPRECATED_MSG | ( | "getRootMeanSquaredTrainingError() is | deprecated, |
use getRMSTrainingError() instead" | , | ||
Float getRootMeanSquaredTrainingError() | const | ||
) |
MLBase::GRT_DEPRECATED_MSG | ( | "getModelTrained() is | deprecated, |
use getTrained() instead" | , | ||
bool getModelTrained() | const | ||
) |
|
virtual |
This saves the model to a file.
filename | the name of the file to save the model to |
Reimplemented in GestureRecognitionPipeline.
Definition at line 190 of file MLBase.cpp.
|
virtual |
This loads a trained model from a file. This function should be overwritten by the derived class.
file | a reference to the file the model will be loaded from |
Reimplemented in SelfOrganizingMap, DTW, ClassLabelTimeoutFilter, FFT, HMM, FiniteStateMachine, RandomForests, AdaBoost, DecisionTree, ANBC, KNN, SVM, MLP, SwipeDetector, RegressionTree, BAG, ZeroCrossingCounter, FIRFilter, KMeansQuantizer, RBMQuantizer, GMM, PrincipalComponentAnalysis, SOMQuantizer, Softmax, MinDist, Node, ClassLabelFilter, MovementTrajectoryFeatures, TimeDomainFeatures, Derivative, LowPassFilter, MultidimensionalRegression, BernoulliRBM, HighPassFilter, FFTFeatures, KMeansFeatures, SavitzkyGolayFilter, MovementIndex, LogisticRegression, ClassLabelChangeFilter, DeadZone, DoubleMovingAverageFilter, EnvelopeExtractor, MedianFilter, MovingAverageFilter, LeakyIntegrator, RMSFilter, WeightedAverageFilter, TimeseriesBuffer, LinearRegression, ParticleClassifier, DiscreteHiddenMarkovModel, ContinuousHiddenMarkovModel, and MovementDetector.
Definition at line 205 of file MLBase.cpp.
|
protected |
Loads the core base settings from a file.
Definition at line 458 of file MLBase.cpp.
|
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.
inputVector | the input vector for mapping/regression |
Definition at line 143 of file MLBase.cpp.
|
virtual |
This is the main mapping interface by reference for all the GRT machine learning algorithms. This should be overwritten by the derived class.
inputVector | a reference to the input vector for mapping/regression |
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.
data | stores the test results data for the current update |
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.
data | stores the training results data for the current update |
Definition at line 415 of file MLBase.cpp.
|
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.
inputVector | the new input vector for prediction |
Definition at line 135 of file MLBase.cpp.
|
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.
inputMatrix | the new input matrix for prediction |
Definition at line 139 of file MLBase.cpp.
|
virtual |
This is the main prediction interface for all the GRT machine learning algorithms. This should be overwritten by the derived class.
inputVector | a reference to the input vector for prediction |
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.
|
virtual |
This is the prediction interface for time series data. This should be overwritten by the derived class.
inputMatrix | a reference to the new input matrix for prediction |
Reimplemented in GestureRecognitionPipeline, DTW, HMM, and ContinuousHiddenMarkovModel.
Definition at line 141 of file MLBase.cpp.
|
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.
Reimplemented in HMM, FiniteStateMachine, ClusterTreeNode, RegressionTreeNode, RandomForests, BernoulliRBM, MLP, ClusterTree, RegressionTree, Node, DiscreteHiddenMarkovModel, ContinuousHiddenMarkovModel, DecisionTreeClusterNode, DecisionTreeThresholdNode, DecisionTreeTripleFeatureNode, and Tree.
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.
observer | the observer you want to register with the learning algorithm |
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.
observer | the observer you want to register with the learning algorithm |
Definition at line 391 of file MLBase.cpp.
bool MLBase::removeAllTestObservers | ( | ) |
Removes all observers from the training result observer manager.
Definition at line 411 of file MLBase.cpp.
bool MLBase::removeAllTrainingObservers | ( | ) |
Removes all observers from the training result observer manager.
Definition at line 407 of file MLBase.cpp.
bool MLBase::removeTestResultsObserver | ( | const Observer< TestInstanceResult > & | observer | ) |
Removes the observer from the test result observer manager.
observer | the observer you want to remove from the learning algorithm |
Definition at line 403 of file MLBase.cpp.
bool MLBase::removeTrainingResultsObserver | ( | const Observer< TrainingResult > & | observer | ) |
Removes the observer from the training result observer manager.
observer | the observer you want to remove from the learning algorithm |
Definition at line 399 of file MLBase.cpp.
|
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.
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.
|
virtual |
This saves the model to a file.
filename | the name of the file to save the model to |
Reimplemented in GestureRecognitionPipeline.
Definition at line 167 of file MLBase.cpp.
|
virtual |
This saves the trained model to a file. This function should be overwritten by the derived class.
file | a reference to the file the model will be saved to |
Reimplemented in SelfOrganizingMap, DTW, ClassLabelTimeoutFilter, FFT, HMM, FiniteStateMachine, RandomForests, AdaBoost, DecisionTree, ANBC, KNN, SVM, MLP, SwipeDetector, RegressionTree, BAG, ZeroCrossingCounter, FIRFilter, PrincipalComponentAnalysis, KMeansQuantizer, RBMQuantizer, GMM, SOMQuantizer, Softmax, Node, MinDist, ClassLabelFilter, MovementTrajectoryFeatures, TimeDomainFeatures, BernoulliRBM, Derivative, LowPassFilter, MultidimensionalRegression, HighPassFilter, FFTFeatures, KMeansFeatures, SavitzkyGolayFilter, MovementIndex, LogisticRegression, ClassLabelChangeFilter, DeadZone, DoubleMovingAverageFilter, EnvelopeExtractor, MedianFilter, MovingAverageFilter, LeakyIntegrator, RMSFilter, WeightedAverageFilter, TimeseriesBuffer, LinearRegression, ParticleClassifier, DiscreteHiddenMarkovModel, ContinuousHiddenMarkovModel, and MovementDetector.
Definition at line 182 of file MLBase.cpp.
|
protected |
Saves the core base settings to a file.
Definition at line 435 of file MLBase.cpp.
bool MLBase::setBatchSize | ( | const UINT | batchSize | ) |
Sets the batch size used during the training phase.
batchSize | the batch size |
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.
learningRate | the learningRate value used during the training phase, must be greater than zero |
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.
maxNumIterations | the maximum number of iterations value, must be greater than zero |
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.
minChange | the minimum change value, must be greater than zero |
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.
minNumEpochs | the minimum number of epochs that can elapse with no change between two training epochs |
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.
numRestarts | number of times a learning algorithm can restart during training |
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.
randomiseTrainingOrder | if true then the order in which training samples are supplied to a learning algorithm will be randomised |
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.
loggingEnabled | if true then training logging will be enabled, if false then training logging will be disabled |
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.
loggingEnabled | if true then training logging will be enabled, if false then training logging will be disabled |
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.
validationSetSize | the new validation set size (as a percentage) |
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.
validationSetSize | the new validation set size (as a percentage) |
Definition at line 361 of file MLBase.cpp.
|
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.
trainingData | the training data that will be used to train the ML model |
Reimplemented in HMM.
Definition at line 107 of file MLBase.cpp.
|
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.
trainingData | the training data that will be used to train a new regression model |
Definition at line 111 of file MLBase.cpp.
|
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.
trainingData | the training data that will be used to train a new regression model |
validationData | the validation data that will be used to validate the regression model |
Definition at line 115 of file MLBase.cpp.
|
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.
trainingData | the training data that will be used to train the ML model |
Definition at line 119 of file MLBase.cpp.
|
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.
trainingData | the training data that will be used to train the ML model |
Definition at line 123 of file MLBase.cpp.
|
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.
trainingData | the training data that will be used to train the ML model |
Definition at line 127 of file MLBase.cpp.
|
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.
trainingData | the training data that will be used to train the ML model |
Definition at line 131 of file MLBase.cpp.
|
virtual |
This is the main training interface for referenced ClassificationData. This should be overwritten by the derived class.
trainingData | a reference to the training data that will be used to train the ML model |
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.
|
virtual |
This is the main training interface for all the regression algorithms. This should be overwritten by the derived class.
trainingData | the training data that will be used to train a new regression model |
Reimplemented in GestureRecognitionPipeline, MLP, MultidimensionalRegression, RegressionTree, LogisticRegression, and LinearRegression.
Definition at line 113 of file MLBase.cpp.
|
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.
trainingData | the training data that will be used to train a new regression model |
validationData | the validation data that will be used to validate the regression model |
Reimplemented in GestureRecognitionPipeline.
Definition at line 117 of file MLBase.cpp.
|
virtual |
This is the main training interface for referenced TimeSeriesClassificationData. This should be overwritten by the derived class.
trainingData | a reference to the training data that will be used to train the ML model |
Reimplemented in GestureRecognitionPipeline, DTW, KMeansQuantizer, RBMQuantizer, SOMQuantizer, KMeansFeatures, HMM, FiniteStateMachine, and ParticleClassifier.
Definition at line 121 of file MLBase.cpp.
|
virtual |
This is the main training interface for referenced ClassificationDataStream. This should be overwritten by the derived class.
trainingData | a reference to the training data that will be used to train the ML model |
Reimplemented in GestureRecognitionPipeline, KMeansQuantizer, RBMQuantizer, SOMQuantizer, KMeansFeatures, and FiniteStateMachine.
Definition at line 125 of file MLBase.cpp.
|
virtual |
This is the main training interface for referenced UnlabelledData. This should be overwritten by the derived class.
trainingData | a reference to the training data that will be used to train the ML model |
Reimplemented in SelfOrganizingMap, GestureRecognitionPipeline, HierarchicalClustering, KMeansQuantizer, RBMQuantizer, SOMQuantizer, KMeansFeatures, KMeans, GaussianMixtureModels, and Clusterer.
Definition at line 129 of file MLBase.cpp.
|
virtual |
This is the main training interface for referenced MatrixFloat data. This should be overwritten by the derived class.
trainingData | a reference to the training data that will be used to train the ML model |
Reimplemented in SelfOrganizingMap, HierarchicalClustering, KMeansQuantizer, RBMQuantizer, SOMQuantizer, KMeansFeatures, KMeans, GaussianMixtureModels, ClusterTree, BernoulliRBM, and Clusterer.
Definition at line 133 of file MLBase.cpp.