GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
GRT::Clusterer Class Reference
Inheritance diagram for GRT::Clusterer:
GRT::MLBase GRT::GRTBase GRT::Observer< TrainingResult > GRT::Observer< TestInstanceResult > GRT::ClusterTree GRT::GaussianMixtureModels GRT::HierarchicalClustering GRT::KMeans GRT::RegisterClustererModule< T > GRT::SelfOrganizingMap GRT::RegisterClustererModule< GRT::ClusterTree > GRT::RegisterClustererModule< GRT::GaussianMixtureModels > GRT::RegisterClustererModule< GRT::HierarchicalClustering > GRT::RegisterClustererModule< GRT::KMeans > GRT::RegisterClustererModule< GRT::SelfOrganizingMap >

Public Types

typedef std::map< string, Clusterer *(*)() > StringClustererMap
 
- Public Types inherited from GRT::MLBase
enum  BaseTypes { BASE_TYPE_NOT_SET =0, CLASSIFIER, REGRESSIFIER, CLUSTERER }
 

Public Member Functions

 Clusterer (void)
 
virtual ~Clusterer (void)
 
virtual bool deepCopyFrom (const Clusterer *Clusterer)
 
bool copyBaseVariables (const Clusterer *Clusterer)
 
virtual bool train_ (MatrixDouble &trainingData)
 
virtual bool train_ (ClassificationData &trainingData)
 
virtual bool train_ (UnlabelledData &trainingData)
 
virtual bool reset ()
 
virtual bool clear ()
 
bool getConverged () const
 
UINT getNumClusters () const
 
UINT getPredictedClusterLabel () const
 
double getMaximumLikelihood () const
 
double getBestDistance () const
 
VectorDouble getClusterLikelihoods () const
 
VectorDouble getClusterDistances () const
 
vector< UINT > getClusterLabels () const
 
string getClustererType () const
 
bool setNumClusters (const UINT numClusters)
 
ClusterercreateNewInstance () const
 
ClustererdeepCopy () const
 
const ClusterergetBaseClusterer () const
 
- Public Member Functions inherited from GRT::MLBase
 MLBase (void)
 
virtual ~MLBase (void)
 
bool copyMLBaseVariables (const MLBase *mlBase)
 
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 (TimeSeriesClassificationDataStream trainingData)
 
virtual bool train_ (TimeSeriesClassificationDataStream &trainingData)
 
virtual bool train (UnlabelledData trainingData)
 
virtual bool train (MatrixDouble data)
 
virtual bool predict (VectorDouble inputVector)
 
virtual bool predict_ (VectorDouble &inputVector)
 
virtual bool predict (MatrixDouble inputMatrix)
 
virtual bool predict_ (MatrixDouble &inputMatrix)
 
virtual bool map (VectorDouble inputVector)
 
virtual bool map_ (VectorDouble &inputVector)
 
virtual bool print () const
 
virtual bool save (const string filename) const
 
virtual bool load (const string filename)
 
virtual bool saveModelToFile (string filename) const
 
virtual bool saveModelToFile (fstream &file) const
 
virtual bool loadModelFromFile (string filename)
 
virtual bool loadModelFromFile (fstream &file)
 
virtual bool getModel (ostream &stream) const
 
double scale (const double &x, const double &minSource, const double &maxSource, const double &minTarget, const double &maxTarget, const bool constrain=false)
 
virtual string getModelAsString () 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
 
double getMinChange () const
 
double getLearningRate () const
 
double getRootMeanSquaredTrainingError () const
 
double getTotalSquaredTrainingError () 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 (bool useScaling)
 
bool setMaxNumEpochs (const UINT maxNumEpochs)
 
bool setMinNumEpochs (const UINT minNumEpochs)
 
bool setMinChange (const double minChange)
 
bool setLearningRate (double learningRate)
 
bool setUseValidationSet (const bool useValidationSet)
 
bool setValidationSetSize (const UINT validationSetSize)
 
bool setRandomiseTrainingOrder (const bool randomiseTrainingOrder)
 
bool registerTrainingResultsObserver (Observer< TrainingResult > &observer)
 
bool registerTestResultsObserver (Observer< TestInstanceResult > &observer)
 
bool removeTrainingResultsObserver (const Observer< TrainingResult > &observer)
 
bool removeTestResultsObserver (const Observer< TestInstanceResult > &observer)
 
bool removeAllTrainingObservers ()
 
bool removeAllTestObservers ()
 
bool notifyTrainingResultsObservers (const TrainingResult &data)
 
bool notifyTestResultsObservers (const TestInstanceResult &data)
 
MLBasegetMLBasePointer ()
 
const MLBasegetMLBasePointer () const
 
vector< TrainingResultgetTrainingResults () const
 
- Public Member Functions inherited from GRT::GRTBase
 GRTBase (void)
 
virtual ~GRTBase (void)
 
bool copyGRTBaseVariables (const GRTBase *GRTBase)
 
string getClassType () const
 
string getLastWarningMessage () const
 
string getLastErrorMessage () const
 
string getLastInfoMessage () const
 
GRTBasegetGRTBasePointer ()
 
const GRTBasegetGRTBasePointer () const
 
- Public Member Functions inherited from GRT::Observer< TrainingResult >
virtual void notify (const TrainingResult &data)
 
- Public Member Functions inherited from GRT::Observer< TestInstanceResult >
virtual void notify (const TestInstanceResult &data)
 

Static Public Member Functions

static ClusterercreateInstanceFromString (string const &ClustererType)
 
static vector< string > getRegisteredClusterers ()
 
- Static Public Member Functions inherited from GRT::GRTBase
static string getGRTVersion (bool returnRevision=true)
 
static string getGRTRevison ()
 

Protected Member Functions

bool saveClustererSettingsToFile (fstream &file) const
 
bool loadClustererSettingsFromFile (fstream &file)
 
- Protected Member Functions inherited from GRT::MLBase
bool saveBaseSettingsToFile (fstream &file) const
 
bool loadBaseSettingsFromFile (fstream &file)
 
- Protected Member Functions inherited from GRT::GRTBase
double SQR (const double &x) const
 

Static Protected Member Functions

static StringClustererMapgetMap ()
 

Protected Attributes

string clustererType
 
UINT numClusters
 Number of clusters in the model.
 
UINT predictedClusterLabel
 Stores the predicted cluster label from the most recent predict( )
 
double maxLikelihood
 
double bestDistance
 
VectorDouble clusterLikelihoods
 
VectorDouble clusterDistances
 
vector< UINT > clusterLabels
 
bool converged
 
vector< MinMaxranges
 
- Protected Attributes inherited from GRT::MLBase
bool trained
 
bool useScaling
 
UINT baseType
 
UINT numInputDimensions
 
UINT numOutputDimensions
 
UINT numTrainingIterationsToConverge
 
UINT minNumEpochs
 
UINT maxNumEpochs
 
UINT validationSetSize
 
double learningRate
 
double minChange
 
double rootMeanSquaredTrainingError
 
double totalSquaredTrainingError
 
bool useValidationSet
 
bool randomiseTrainingOrder
 
Random random
 
vector< TrainingResulttrainingResults
 
TrainingResultsObserverManager trainingResultsObserverManager
 
TestResultsObserverManager testResultsObserverManager
 
- Protected Attributes inherited from GRT::GRTBase
string classType
 
DebugLog debugLog
 
ErrorLog errorLog
 
InfoLog infoLog
 
TrainingLog trainingLog
 
TestingLog testingLog
 
WarningLog warningLog
 

Detailed Description

Definition at line 38 of file Clusterer.h.

Member Typedef Documentation

typedef std::map< string, Clusterer*(*)() > GRT::Clusterer::StringClustererMap

Defines a map between a string (which will contain the name of the Clusterer, such as KMeans) and a function returns a new instance of that Clusterer

Definition at line 190 of file Clusterer.h.

Constructor & Destructor Documentation

GRT::Clusterer::Clusterer ( void  )

Default Clusterer Constructor

Definition at line 63 of file Clusterer.cpp.

GRT::Clusterer::~Clusterer ( void  )
virtual

Default Clusterer Destructor

Definition at line 77 of file Clusterer.cpp.

Member Function Documentation

bool GRT::Clusterer::clear ( )
virtual

This function clears the Clusterer 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 from GRT::MLBase.

Reimplemented in GRT::SelfOrganizingMap, GRT::HierarchicalClustering, GRT::ClusterTree, GRT::KMeans, and GRT::GaussianMixtureModels.

Definition at line 139 of file Clusterer.cpp.

bool GRT::Clusterer::copyBaseVariables ( const Clusterer Clusterer)

This copies the Clusterer base class variables from the Clusterer pointer to this instance.

Parameters
constClusterer *Clusterer: a pointer to a Clusterer from which the values will be copied to this instance
Returns
returns true if the copy was successfull, false otherwise

Definition at line 84 of file Clusterer.cpp.

Clusterer * GRT::Clusterer::createInstanceFromString ( string const &  ClustererType)
static

Creates a new Clusterer instance based on the input string (which should contain the name of a valid Clusterer such as KMeans).

Parameters
stringconst &ClustererType: the name of the Clusterer
Returns
Clusterer*: a pointer to the new instance of the Clusterer

Definition at line 27 of file Clusterer.cpp.

Clusterer * GRT::Clusterer::createNewInstance ( ) const

Creates a new Clusterer instance based on the current clustererType string value.

Returns
Clusterer*: a pointer to the new instance of the Clusterer

Definition at line 35 of file Clusterer.cpp.

Clusterer * GRT::Clusterer::deepCopy ( ) const

This creates a new Clusterer 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.

Returns
returns a pointer to a new Clusterer instance which is a deep copy of this instance

Definition at line 39 of file Clusterer.cpp.

virtual bool GRT::Clusterer::deepCopyFrom ( const Clusterer Clusterer)
inlinevirtual

This is the base deep copy function for the Clusterer modules. This function should be overwritten by the derived class. This deep copies the variables and models from the Clusterer pointer to this Clusterer instance.

Parameters
constClusterer *Clusterer: a pointer to the Clusterer base class, this should be pointing to another instance of a matching derived class
Returns
returns true if the clone was successfull, false otherwise (the Clusterer base class will always return flase)

Reimplemented in GRT::SelfOrganizingMap, GRT::HierarchicalClustering, GRT::ClusterTree, GRT::KMeans, and GRT::GaussianMixtureModels.

Definition at line 58 of file Clusterer.h.

const Clusterer & GRT::Clusterer::getBaseClusterer ( ) const

Returns a pointer to this Clusterer. This is useful for a derived class so it can get easy access to this base Clusterer.

Returns
Clusterer&: a reference to this Clusterer

Definition at line 259 of file Clusterer.cpp.

double GRT::Clusterer::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.

Returns
returns the current bestDistance value

Definition at line 241 of file Clusterer.cpp.

VectorDouble GRT::Clusterer::getClusterDistances ( ) const

Gets a vector of the cluster distances from the last prediction, this will be an N-dimensional vector, where N is the number of clusters in the model. The exact form of these distances depends on the cluster algorithm.

Returns
returns a vector of the cluster distances from the last prediction, an empty vector will be returned if the model has not been trained

Definition at line 249 of file Clusterer.cpp.

string GRT::Clusterer::getClustererType ( ) const

Returns the classifeir type as a string.

Returns
returns the Clusterer type as a string

Definition at line 257 of file Clusterer.cpp.

vector< UINT > GRT::Clusterer::getClusterLabels ( ) const

Gets a vector of unsigned ints containing the label of each cluster, this will be an K-dimensional vector, where K is the number of clusters in the model.

Returns
returns a vector of unsigned ints containing the label of each cluster, an empty vector will be returned if the model has not been trained

Definition at line 253 of file Clusterer.cpp.

VectorDouble GRT::Clusterer::getClusterLikelihoods ( ) const

Gets a vector of the cluster likelihoods from the last prediction, this will be an N-dimensional vector, where N is the number of clusters in the model. The exact form of these likelihoods depends on the cluster algorithm.

Returns
returns a vector of the cluster likelihoods from the last prediction, an empty vector will be returned if the model has not been trained

Definition at line 245 of file Clusterer.cpp.

bool GRT::Clusterer::getConverged ( ) const

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

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

Definition at line 227 of file Clusterer.cpp.

double GRT::Clusterer::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.

Returns
returns the current maximumLikelihood value

Definition at line 237 of file Clusterer.cpp.

UINT GRT::Clusterer::getNumClusters ( ) const

Returns the number of clusters in the model.

Returns
returns the number of clusters

Definition at line 232 of file Clusterer.cpp.

UINT GRT::Clusterer::getPredictedClusterLabel ( ) const

Returns the predicted cluster label.

Returns
returns the predicted cluster label

Definition at line 234 of file Clusterer.cpp.

vector< string > GRT::Clusterer::getRegisteredClusterers ( )
static

Returns a vector of the names of all Clusterers that have been registered with the base Clusterer.

Returns
vector< string >: a vector containing the names of the Clusterers that have been registered with the base Clusterer

Definition at line 52 of file Clusterer.cpp.

bool GRT::Clusterer::loadClustererSettingsFromFile ( fstream &  file)
protected

Loads the core clusterer settings from a file.

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

Definition at line 176 of file Clusterer.cpp.

bool GRT::Clusterer::reset ( )
virtual

This resets the Clusterer. This overrides the reset function in the MLBase base class.

Returns
returns true if the Clusterer was reset, false otherwise

Reimplemented from GRT::MLBase.

Reimplemented in GRT::SelfOrganizingMap, GRT::HierarchicalClustering, GRT::KMeans, and GRT::GaussianMixtureModels.

Definition at line 125 of file Clusterer.cpp.

bool GRT::Clusterer::saveClustererSettingsToFile ( fstream &  file) const
protected

Saves the core clusterer settings to a file.

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

Definition at line 154 of file Clusterer.cpp.

bool GRT::Clusterer::setNumClusters ( const UINT  numClusters)

Sets the number of clusters that will be used the next time a model is trained. This will clear any previous model. The number of clusters must be greater than zero.

Parameters
UINTnumClusters: the number of clusters, must be greater than zero
Returns
returns true if the value was updated successfully, false otherwise

Definition at line 263 of file Clusterer.cpp.

bool GRT::Clusterer::train_ ( MatrixDouble trainingData)
virtual

This is the main interface for training the clusterer model.

Parameters
MatrixDouble&trainingData: a reference to the training data that will be used to train the ML model
Returns
returns true if the model was successfully trained, false otherwise

Reimplemented from GRT::MLBase.

Reimplemented in GRT::SelfOrganizingMap, GRT::HierarchicalClustering, GRT::KMeans, GRT::GaussianMixtureModels, and GRT::ClusterTree.

Definition at line 111 of file Clusterer.cpp.

bool GRT::Clusterer::train_ ( ClassificationData trainingData)
virtual

Override the main ClassificationData train function to pass MatrixDouble data to the Clusterer train function.

Parameters
ClassificationData&trainingData: a reference to the training data that will be used to train the ML model
Returns
returns true if the model was successfully trained, false otherwise

Reimplemented from GRT::MLBase.

Reimplemented in GRT::SelfOrganizingMap, GRT::HierarchicalClustering, GRT::KMeans, and GRT::GaussianMixtureModels.

Definition at line 115 of file Clusterer.cpp.

bool GRT::Clusterer::train_ ( UnlabelledData trainingData)
virtual

Override the main UnlabelledData train function to pass MatrixDouble data to the Clusterer train function.

Parameters
UnlabelledData&trainingData: a reference to the training data that will be used to train the ML model
Returns
returns true if the model was successfully trained, false otherwise

Reimplemented from GRT::MLBase.

Reimplemented in GRT::SelfOrganizingMap, GRT::HierarchicalClustering, GRT::KMeans, and GRT::GaussianMixtureModels.

Definition at line 120 of file Clusterer.cpp.


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