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.
PostProcessing Class Reference

#include <PostProcessing.h>

Inheritance diagram for PostProcessing:
MLBase GRTBase Observer< TrainingResult > Observer< TestInstanceResult > ClassLabelChangeFilter ClassLabelFilter ClassLabelTimeoutFilter RegisterPostProcessingModule< T > RegisterPostProcessingModule< ClassLabelChangeFilter > RegisterPostProcessingModule< ClassLabelFilter > RegisterPostProcessingModule< ClassLabelTimeoutFilter >

Public Types

enum  PostprocessingInputModes { INPUT_MODE_NOT_SET =0, INPUT_MODE_PREDICTED_CLASS_LABEL, INPUT_MODE_CLASS_LIKELIHOODS }
 
enum  PostprocessingOutputModes { OUTPUT_MODE_NOT_SET =0, OUTPUT_MODE_PREDICTED_CLASS_LABEL, OUTPUT_MODE_CLASS_LIKELIHOODS }
 
typedef std::map< std::string, PostProcessing *(*)() > StringPostProcessingMap
 
- Public Types inherited from MLBase
enum  BaseTypes { BASE_TYPE_NOT_SET =0, CLASSIFIER, REGRESSIFIER, CLUSTERER }
 

Public Member Functions

 PostProcessing (void)
 
virtual ~PostProcessing (void)
 
virtual bool deepCopyFrom (const PostProcessing *postProcessing)
 
bool copyBaseVariables (const PostProcessing *postProcessingModule)
 
virtual bool process (const VectorFloat &inputVector)
 
virtual bool reset ()
 
virtual bool saveModelToFile (std::string filename) const
 
virtual bool loadModelFromFile (std::string filename)
 
virtual bool saveModelToFile (std::fstream &file) const
 
virtual bool loadModelFromFile (std::fstream &file)
 
std::string getPostProcessingType () const
 
UINT getPostProcessingInputMode () const
 
UINT getPostProcessingOutputMode () const
 
UINT getNumInputDimensions () const
 
UINT getNumOutputDimensions () const
 
bool getInitialized () const
 
bool getIsPostProcessingInputModePredictedClassLabel () const
 
bool getIsPostProcessingInputModeClassLikelihoods () const
 
bool getIsPostProcessingOutputModePredictedClassLabel () const
 
bool getIsPostProcessingOutputModeClassLikelihoods () const
 
VectorFloat getProcessedData () const
 
PostProcessingcreateNewInstance () 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 clear ()
 
virtual bool print () const
 
virtual bool save (const std::string filename) const
 
virtual bool load (const std::string filename)
 
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)
 

Static Public Member Functions

static PostProcessingcreateInstanceFromString (std::string const &postProcessingType)
 
- Static Public Member Functions inherited from GRTBase
static std::string getGRTVersion (bool returnRevision=true)
 
static std::string getGRTRevison ()
 

Protected Member Functions

bool init ()
 
bool savePostProcessingSettingsToFile (std::fstream &file) const
 
bool loadPostProcessingSettingsFromFile (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 StringPostProcessingMapgetMap ()
 

Protected Attributes

std::string postProcessingType
 
bool initialized
 
UINT postProcessingInputMode
 
UINT postProcessingOutputMode
 
VectorFloat processedData
 
- 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
 

Detailed Description

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 38 of file PostProcessing.h.

Member Typedef Documentation

typedef std::map< std::string, PostProcessing*(*)() > PostProcessing::StringPostProcessingMap

This typedef defines a map between a string and a PostProcessing pointer.

Definition at line 183 of file PostProcessing.h.

Constructor & Destructor Documentation

PostProcessing::PostProcessing ( void  )

Default Constructor

Definition at line 37 of file PostProcessing.cpp.

PostProcessing::~PostProcessing ( void  )
virtual

Default Destructor

Definition at line 47 of file PostProcessing.cpp.

Member Function Documentation

bool PostProcessing::copyBaseVariables ( const PostProcessing postProcessingModule)

This copies the PostProcessing variables from postProcessingModule to the instance that calls the function.

Parameters
postProcessingModulea pointer to a post processing module from which the values will be copied
Returns
returns true if the copy was successfull, false otherwise

Definition at line 54 of file PostProcessing.cpp.

PostProcessing * PostProcessing::createInstanceFromString ( std::string const &  postProcessingType)
static

This static function will dynamically create a new PostProcessing instance from a string.

Parameters
postProcessingTypethe name of the PostProcessing class you want to dynamically create
Returns
a pointer to the new PostProcessing instance that was created

Definition at line 28 of file PostProcessing.cpp.

PostProcessing * PostProcessing::createNewInstance ( ) const

This static function will dynamically create a new PostProcessing instance based on the type of this instance

Definition at line 169 of file PostProcessing.cpp.

virtual bool PostProcessing::deepCopyFrom ( const PostProcessing postProcessing)
inlinevirtual

This is the base deepCopyFrom function for the PostProcessing modules. This function should be overwritten by the derived class.

Parameters
postProcessinga pointer to the PostProcessing base class, this should be pointing to another instance of a matching derived class
Returns
returns true if the deep copy was successfull, false otherwise (the PostProcessing base class will always return flase)

Reimplemented in ClassLabelTimeoutFilter, ClassLabelFilter, and ClassLabelChangeFilter.

Definition at line 57 of file PostProcessing.h.

bool PostProcessing::getInitialized ( ) const

Returns true if the post processing module has been initialized correctly.

Returns
returns true if the post processing module has been initialized succesfully, false otherwise

Definition at line 193 of file PostProcessing.cpp.

bool PostProcessing::getIsPostProcessingInputModeClassLikelihoods ( ) const
Returns
returns true if input mode is INPUT_MODE_CLASS_LIKELIHOODS, false otherwise

Definition at line 201 of file PostProcessing.cpp.

bool PostProcessing::getIsPostProcessingInputModePredictedClassLabel ( ) const
Returns
returns true if input mode is INPUT_MODE_PREDICTED_CLASS_LABEL, false otherwise

Definition at line 197 of file PostProcessing.cpp.

bool PostProcessing::getIsPostProcessingOutputModeClassLikelihoods ( ) const
Returns
returns true if input mode is OUTPUT_MODE_CLASS_LIKELIHOODS, false otherwise

Definition at line 209 of file PostProcessing.cpp.

bool PostProcessing::getIsPostProcessingOutputModePredictedClassLabel ( ) const
Returns
returns true if input mode is OUTPUT_MODE_PREDICTED_CLASS_LABEL, false otherwise

Definition at line 205 of file PostProcessing.cpp.

UINT PostProcessing::getNumInputDimensions ( ) const

Returns the size of the input vector expected by the post processing module.

Returns
returns the size of the input vector expected by the post processing module

Definition at line 185 of file PostProcessing.cpp.

UINT PostProcessing::getNumOutputDimensions ( ) const

Returns the size of the vector that will be computed by the post processing module.

Returns
returns the size of the vector that will be computed by the post processing module

Definition at line 189 of file PostProcessing.cpp.

UINT PostProcessing::getPostProcessingInputMode ( ) const
Returns
returns the post processing input mode, this will be one of the PostprocessingInputModes enums

Definition at line 177 of file PostProcessing.cpp.

UINT PostProcessing::getPostProcessingOutputMode ( ) const
Returns
returns the post processing output mode, this will be one of the PostprocessingOutputModes enums

Definition at line 181 of file PostProcessing.cpp.

std::string PostProcessing::getPostProcessingType ( ) const
Returns
returns the post processing type as a string, e.g. ClassLabelTimeoutFilter

Definition at line 173 of file PostProcessing.cpp.

VectorFloat PostProcessing::getProcessedData ( ) const
Returns
returns a VectorFloat containing the most recent processed data

Definition at line 213 of file PostProcessing.cpp.

bool PostProcessing::init ( )
protected

Initializes the base postprocessing module, this will resize the processedData vector and get the instance ready for processing new data. The inheriting class must first initialize the module before calling this function.

Returns
returns true if the module was initialized, false otherwise

Definition at line 78 of file PostProcessing.cpp.

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

This saves the post processing settings to a file. This function should be overwritten by the derived class.

Parameters
filea reference to the file to save the settings to
Returns
returns true if the settings were saved successfully, false otherwise

Reimplemented from MLBase.

Reimplemented in ClassLabelTimeoutFilter, ClassLabelFilter, and ClassLabelChangeFilter.

Definition at line 109 of file PostProcessing.cpp.

virtual bool PostProcessing::loadModelFromFile ( std::fstream &  file)
inlinevirtual

This loads the post processing settings from a file. This function should be overwritten by the derived class.

Parameters
filea reference to the file to load the settings from
Returns
returns true if the settings were loaded successfully, false otherwise (the base class always returns false)

Reimplemented from MLBase.

Reimplemented in ClassLabelTimeoutFilter, ClassLabelFilter, and ClassLabelChangeFilter.

Definition at line 117 of file PostProcessing.h.

bool PostProcessing::loadPostProcessingSettingsFromFile ( std::fstream &  file)
protected

Loads the core postprocessing settings from a file.

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

Definition at line 138 of file PostProcessing.cpp.

virtual bool PostProcessing::process ( const VectorFloat inputVector)
inlinevirtual

This is the main processing interface for all the post processing modules and should be overwritten by the inheriting class.

Parameters
inputVectora vector containing the data that should be processed
Returns
returns true if the post processing was successfull, false otherwise

Reimplemented in ClassLabelTimeoutFilter, ClassLabelFilter, and ClassLabelChangeFilter.

Definition at line 73 of file PostProcessing.h.

virtual bool PostProcessing::reset ( )
inlinevirtual

This function is called by the GestureRecognitionPipeline's reset function and will reset the PostProcessing module. This function should be overwritten by the derived class.

Returns
returns true if the module was reset, false otherwise (the base class always returns true)

Reimplemented from MLBase.

Reimplemented in ClassLabelTimeoutFilter, ClassLabelFilter, and ClassLabelChangeFilter.

Definition at line 81 of file PostProcessing.h.

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

This saves the post processing settings to a file. This function should be overwritten by the derived class.

Parameters
filenamethe filename to save the settings to
Returns
returns true if the settings were saved successfully, false otherwise

Reimplemented from MLBase.

Reimplemented in ClassLabelTimeoutFilter, ClassLabelFilter, and ClassLabelChangeFilter.

Definition at line 95 of file PostProcessing.cpp.

virtual bool PostProcessing::saveModelToFile ( std::fstream &  file) const
inlinevirtual

This saves the post processing settings to a file. This function should be overwritten by the derived class.

Parameters
filea reference to the file to save the settings to
Returns
returns true if the settings were saved successfully, false otherwise (the base class always returns false)

Reimplemented from MLBase.

Reimplemented in ClassLabelTimeoutFilter, ClassLabelFilter, and ClassLabelChangeFilter.

Definition at line 108 of file PostProcessing.h.

bool PostProcessing::savePostProcessingSettingsToFile ( std::fstream &  file) const
protected

Saves the core postprocessing settings to a file.

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

Definition at line 124 of file PostProcessing.cpp.


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