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.
|
Public Types | |
typedef std::map< std::string, Classifier *(*)() > | StringClassifierMap |
Public Types inherited from MLBase | |
enum | BaseTypes { BASE_TYPE_NOT_SET =0, CLASSIFIER, REGRESSIFIER, CLUSTERER } |
Public Member Functions | |
Classifier (void) | |
virtual | ~Classifier (void) |
virtual bool | deepCopyFrom (const Classifier *classifier) |
bool | copyBaseVariables (const Classifier *classifier) |
virtual bool | reset () |
virtual bool | clear () |
std::string | getClassifierType () const |
bool | getSupportsNullRejection () const |
bool | getNullRejectionEnabled () const |
Float | getNullRejectionCoeff () const |
Float | getMaximumLikelihood () const |
Float | getBestDistance () const |
Float | getPhase () const |
virtual UINT | getNumClasses () const |
UINT | getClassLabelIndexValue (UINT classLabel) const |
UINT | getPredictedClassLabel () const |
VectorFloat | getClassLikelihoods () const |
VectorFloat | getClassDistances () const |
VectorFloat | getNullRejectionThresholds () const |
Vector< UINT > | getClassLabels () const |
Vector< MinMax > | getRanges () const |
bool | enableNullRejection (bool useNullRejection) |
virtual bool | setNullRejectionCoeff (Float nullRejectionCoeff) |
virtual bool | setNullRejectionThresholds (VectorFloat newRejectionThresholds) |
virtual bool | recomputeNullRejectionThresholds () |
bool | getTimeseriesCompatible () const |
Classifier * | createNewInstance () const |
Classifier * | deepCopy () const |
const Classifier * | getClassifierPointer () const |
const Classifier & | getBaseClassifier () const |
Public Member Functions inherited from MLBase | |
MLBase (void) | |
virtual | ~MLBase (void) |
bool | copyMLBaseVariables (const MLBase *mlBase) |
virtual bool | train (ClassificationData trainingData) |
virtual bool | train_ (ClassificationData &trainingData) |
virtual bool | train (RegressionData trainingData) |
virtual bool | train_ (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 | 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) |
MLBase * | getMLBasePointer () |
const MLBase * | getMLBasePointer () 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) |
GRTBase * | getGRTBasePointer () |
const GRTBase * | getGRTBasePointer () 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) |
Static Public Member Functions | |
static Classifier * | createInstanceFromString (std::string const &classifierType) |
static Vector< std::string > | getRegisteredClassifiers () |
Static Public Member Functions inherited from GRTBase | |
static std::string | getGRTVersion (bool returnRevision=true) |
static std::string | getGRTRevison () |
Protected Types | |
enum | ClassifierModes { STANDARD_CLASSIFIER_MODE =0, TIMESERIES_CLASSIFIER_MODE } |
Protected Member Functions | |
bool | saveBaseSettingsToFile (std::fstream &file) const |
bool | loadBaseSettingsFromFile (std::fstream &file) |
Protected Member Functions inherited from MLBase | |
bool | saveBaseSettingsToFile (std::fstream &file) const |
bool | loadBaseSettingsFromFile (std::fstream &file) |
Protected Member Functions inherited from GRTBase | |
Float | SQR (const Float &x) const |
Static Protected Member Functions | |
static StringClassifierMap * | getMap () |
Protected Attributes | |
std::string | classifierType |
bool | supportsNullRejection |
bool | useNullRejection |
UINT | numClasses |
UINT | predictedClassLabel |
UINT | classifierMode |
Float | nullRejectionCoeff |
Float | maxLikelihood |
Float | bestDistance |
Float | phase |
VectorFloat | classLikelihoods |
VectorFloat | classDistances |
VectorFloat | nullRejectionThresholds |
Vector< UINT > | classLabels |
Vector< MinMax > | ranges |
Protected Attributes inherited from MLBase | |
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 |
Definition at line 41 of file Classifier.h.
typedef std::map< std::string, Classifier*(*)() > Classifier::StringClassifierMap |
Defines a map between a string (which will contain the name of the classifier, such as ANBC) and a function returns a new instance of that classifier
Definition at line 248 of file Classifier.h.
Classifier::Classifier | ( | void | ) |
Default Classifier Constructor
Definition at line 68 of file Classifier.cpp.
|
virtual |
Default Classifier Destructor
Definition at line 85 of file Classifier.cpp.
|
virtual |
This function clears the classifier module, removing any trained model and setting all the base variables to their default values.
Reimplemented from MLBase.
Reimplemented in DTW, HMM, FiniteStateMachine, AdaBoost, ANBC, SVM, KNN, RandomForests, DecisionTree, BAG, GMM, ParticleClassifier, MinDist, Softmax, and SwipeDetector.
Definition at line 141 of file Classifier.cpp.
bool Classifier::copyBaseVariables | ( | const Classifier * | classifier | ) |
This copies the Classifier base class variables from the classifier pointer to this instance.
classifier | a pointer to a classifier from which the values will be copied to this instance |
Definition at line 92 of file Classifier.cpp.
|
static |
Creates a new classifier instance based on the input string (which should contain the name of a valid classifier such as ANBC).
classifierType | the name of the classifier |
Definition at line 28 of file Classifier.cpp.
Classifier * Classifier::createNewInstance | ( | ) | const |
Creates a new classifier instance based on the current classifierType string value.
Definition at line 36 of file Classifier.cpp.
Classifier * Classifier::deepCopy | ( | ) | const |
This creates a new Classifier instance and deep copies the variables and models from this instance into the deep copy. The function will then return a pointer to the new instance. It is up to the user who calls this function to delete the dynamic instance when they are finished using it.
Definition at line 40 of file Classifier.cpp.
|
inlinevirtual |
This is the base deep copy function for the Classifier modules. This function should be overwritten by the derived class. This deep copies the variables and models from the classifier pointer to this classifier instance.
classifier | a pointer to the Classifier base class, this should be pointing to another instance of a matching derived class |
Reimplemented in DTW, AdaBoost, SVM, LDA, KNN, RandomForests, DecisionTree, ANBC, HMM, GMM, BAG, MinDist, Softmax, SwipeDetector, FiniteStateMachine, and ParticleClassifier.
Definition at line 61 of file Classifier.h.
bool Classifier::enableNullRejection | ( | bool | useNullRejection | ) |
Sets if the classifier should use nullRejection.
If set to true then the classifier will reject a predicted class label if the likelihood of the prediction is below (or above depending on the algorithm) the models rejectionThreshold. If a prediction is rejected then the default null class label of 0 will be returned. If set to false then the classifier will simply return the most likely predicted class.
Definition at line 230 of file Classifier.cpp.
const Classifier & Classifier::getBaseClassifier | ( | ) | const |
Returns a pointer to this classifier. This is useful for a derived class so it can get easy access to this base classifier.
Definition at line 251 of file Classifier.cpp.
Float Classifier::getBestDistance | ( | ) | const |
Returns the current bestDistance value. The bestDistance value is computed during the prediction phase and is either the minimum or maximum distance, depending on the algorithm. This value will return 0 if a prediction has not been made.
Definition at line 185 of file Classifier.cpp.
VectorFloat Classifier::getClassDistances | ( | ) | const |
Gets a Vector of the class distances from the last prediction, this will be an N-dimensional Vector, where N is the number of classes in the model. The exact form of these distances depends on the classification algorithm.
Definition at line 212 of file Classifier.cpp.
const Classifier * Classifier::getClassifierPointer | ( | ) | const |
Returns a pointer to the classifier.
Definition at line 53 of file Classifier.cpp.
std::string Classifier::getClassifierType | ( | ) | const |
Returns the classifier type as a string.
Definition at line 160 of file Classifier.cpp.
UINT Classifier::getClassLabelIndexValue | ( | UINT | classLabel | ) | const |
Gets the index of the query classLabel in the classLabels Vector. If the query classLabel does not exist in the classLabels Vector then the function will return zero.
classLabel | the query classLabel |
Definition at line 194 of file Classifier.cpp.
Vector< UINT > Classifier::getClassLabels | ( | ) | const |
Gets a Vector containing the label each class represents, this will be an N-dimensional Vector, where N is the number of classes in the model. This is useful if the model was trained with non-monotonically class labels (i.e. class labels such as [1, 3, 6, 9, 12] instead of [1, 2, 3, 4, 5]).
Definition at line 222 of file Classifier.cpp.
VectorFloat Classifier::getClassLikelihoods | ( | ) | const |
Gets a Vector of the class likelihoods from the last prediction, this will be an N-dimensional Vector, where N is the number of classes in the model. The exact form of these likelihoods depends on the classification algorithm.
Definition at line 207 of file Classifier.cpp.
Float Classifier::getMaximumLikelihood | ( | ) | const |
Returns the current maximumLikelihood value. The maximumLikelihood value is computed during the prediction phase and is the likelihood of the most likely model. This value will return 0 if a prediction has not been made.
Definition at line 176 of file Classifier.cpp.
Float Classifier::getNullRejectionCoeff | ( | ) | const |
Returns the current nullRejectionCoeff value. The nullRejectionCoeff parameter is a multipler controlling the null rejection threshold for each class.
Definition at line 172 of file Classifier.cpp.
bool Classifier::getNullRejectionEnabled | ( | ) | const |
Returns true if nullRejection is enabled.
Definition at line 168 of file Classifier.cpp.
VectorFloat Classifier::getNullRejectionThresholds | ( | ) | const |
Gets a Vector containing the null rejection thresholds for each class, this will be an N-dimensional Vector, where N is the number of classes in the model.
Definition at line 217 of file Classifier.cpp.
|
virtual |
Gets the number of classes in trained model.
Reimplemented in SVM.
Definition at line 190 of file Classifier.cpp.
Float Classifier::getPhase | ( | ) | const |
This function returns the estimated gesture phase from the most recent prediction. This value is only relevant if the classifier supports timeseries classification.
Definition at line 181 of file Classifier.cpp.
UINT Classifier::getPredictedClassLabel | ( | ) | const |
Gets the predicted class label from the last prediction.
Definition at line 202 of file Classifier.cpp.
Gets a Vector of the ranges used to scale the data for training and prediction, these ranges are only used if the classifier has been trained with the #useScaling flag set to true. This should be an N-dimensional Vector, where N is the number of features in your data.
Definition at line 226 of file Classifier.cpp.
|
static |
Returns a Vector of the names of all classifiers that have been registered with the base classifier.
Definition at line 57 of file Classifier.cpp.
bool Classifier::getSupportsNullRejection | ( | ) | const |
Returns true if the classifier instance supports null rejection, false otherwise.
Definition at line 164 of file Classifier.cpp.
|
inline |
Indicates if the classifier can be used to classify timeseries data. If true then the classifier can accept training data in the LabelledTimeSeriesClassificationData format.
return returns true if the classifier can be used to classify timeseries data, false otherwise
Definition at line 243 of file Classifier.h.
|
protected |
Loads the core base settings from a file.
Definition at line 302 of file Classifier.cpp.
|
inlinevirtual |
Recomputes the null rejection thresholds for each model.
Reimplemented in DTW, AdaBoost, ANBC, KNN, GMM, MinDist, and DecisionTree.
Definition at line 235 of file Classifier.h.
|
virtual |
This resets the classifier. This overrides the reset function in the MLBase base class.
Reimplemented from MLBase.
Reimplemented in DTW, HMM, FiniteStateMachine, ParticleClassifier, ANBC, SwipeDetector, and BAG.
Definition at line 122 of file Classifier.cpp.
|
protected |
Saves the core base settings to a file.
Definition at line 255 of file Classifier.cpp.
|
virtual |
Sets the nullRejectionCoeff, this is a multipler controlling the null rejection threshold for each class.
Reimplemented in KNN, AdaBoost, and MinDist.
Definition at line 235 of file Classifier.cpp.
|
virtual |
Manually sets the nullRejectionThresholds, these are the thresholds used for null rejection for each class. This needs to be called after the model has been trained. Calling the setNullRejectionCoeff or recomputeNullRejectionThresholds functions will override these values. The size of the newRejectionThresholds Vector must match the number of classes in the model.
newRejectionThresholds | the new rejection thresholds |
Definition at line 243 of file Classifier.cpp.