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::PrincipalComponentAnalysis Class Reference
Inheritance diagram for GRT::PrincipalComponentAnalysis:
GRT::GRTBase

Public Member Functions

 PrincipalComponentAnalysis ()
 
virtual ~PrincipalComponentAnalysis ()
 
bool computeFeatureVector (const MatrixDouble &data, double maxVariance=0.95, bool normData=false)
 
bool computeFeatureVector (const MatrixDouble &data, UINT numPrincipalComponents, bool normData=false)
 
bool project (const MatrixDouble &data, MatrixDouble &prjData)
 
bool project (const VectorDouble &data, VectorDouble &prjData)
 
bool getTrained () const
 
bool getNormData () const
 
UINT getNumInputDimensions () const
 
UINT getNumPrincipalComponents () const
 
double getMaxVariance () const
 
VectorDouble getMeanVector () const
 
VectorDouble getStdDevVector () const
 
VectorDouble getComponentWeights () const
 
VectorDouble getEigenValues () const
 
virtual bool print (string title="") const
 
MatrixDouble getEigenVectors () 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
 

Protected Types

enum  AnalysisMode { MAX_VARIANCE =0, MAX_NUM_PCS }
 

Protected Member Functions

bool computeFeatureVector_ (const MatrixDouble &data, UINT analysisMode)
 
- Protected Member Functions inherited from GRT::GRTBase
double SQR (const double &x) const
 

Protected Attributes

bool trained
 
bool normData
 
UINT numInputDimensions
 
UINT numPrincipalComponents
 
double maxVariance
 
VectorDouble mean
 
VectorDouble stdDev
 
VectorDouble componentWeights
 
VectorDouble eigenvalues
 
vector< IndexedDoublesortedEigenvalues
 
MatrixDouble eigenvectors
 
ErrorLog errorLog
 
WarningLog warningLog
 
- Protected Attributes inherited from GRT::GRTBase
string classType
 
DebugLog debugLog
 
ErrorLog errorLog
 
InfoLog infoLog
 
TrainingLog trainingLog
 
TestingLog testingLog
 
WarningLog warningLog
 

Additional Inherited Members

- Static Public Member Functions inherited from GRT::GRTBase
static string getGRTVersion (bool returnRevision=true)
 
static string getGRTRevison ()
 

Detailed Description

Definition at line 51 of file PrincipalComponentAnalysis.h.

Constructor & Destructor Documentation

GRT::PrincipalComponentAnalysis::PrincipalComponentAnalysis ( )

Default constructor.

Definition at line 30 of file PrincipalComponentAnalysis.cpp.

GRT::PrincipalComponentAnalysis::~PrincipalComponentAnalysis ( )
virtual

Default destructor.

Definition at line 42 of file PrincipalComponentAnalysis.cpp.

Member Function Documentation

bool GRT::PrincipalComponentAnalysis::computeFeatureVector ( const MatrixDouble data,
double  maxVariance = 0.95,
bool  normData = false 
)

Runs the principal component analysis algorithm on the input data and builds the resulting feature vector so new data can be projected onto the principal subspace (using the project function). The number of principal components is automatically computed by selecting the minimum number of components that reach the maxVariance value. This should be a value between [0 1], the default value of 0.95 represents 95% of the variance in the original dataset.

Parameters
constMatrixDouble &data: a matrix containing the data from which the principal components will be computed. This should be an [M N] matrix, where M==samples and N==dimensions.
doublemaxVariance: sets the variance that should represented by the top K principal components. This should be a value between [0 1]. Default value=0.95
boolnormData: sets if the data will be z-normalized before running the PCA algorithm. Default value=false
Returns
returns true if the principal components of the input matrix could be computed, false otherwise value

Definition at line 46 of file PrincipalComponentAnalysis.cpp.

bool GRT::PrincipalComponentAnalysis::computeFeatureVector ( const MatrixDouble data,
UINT  numPrincipalComponents,
bool  normData = false 
)

Runs the principal component analysis algorithm on the input data and builds the resulting feature vector so new data can be projected onto the principal subspace (using the project function). The number of principal components should be set be the user and must be less than or equal to the number of dimensions in the input data.

Parameters
constMatrixDouble &data: a matrix containing the data from which the principal components will be computed. This should be an [M N] matrix, where M==samples and N==dimensions
UINTnumPrincipalComponents: sets the number of principal components. This must be a value be less than or equal to the number of dimensions in the input data
boolnormData: sets if the data will be z-normalized before running the PCA algorithm. Default value=false
Returns
returns true if the principal components of the input matrix could be computed, false otherwise value

Definition at line 53 of file PrincipalComponentAnalysis.cpp.

VectorDouble GRT::PrincipalComponentAnalysis::getComponentWeights ( ) const
inline

Returns the weights for each principal component, these weights sum to 1.

Returns
returns a vector of the weights for each principal component, these weights sum to 1

Definition at line 162 of file PrincipalComponentAnalysis.h.

VectorDouble GRT::PrincipalComponentAnalysis::getEigenValues ( ) const
inline

Returns the raw eigen values (these are not sorted).

Returns
returns a vector of the raw eigen values

Definition at line 168 of file PrincipalComponentAnalysis.h.

MatrixDouble GRT::PrincipalComponentAnalysis::getEigenVectors ( ) const

Returns a matrix containing the eigen vectors.

Returns
returns a matrix containing the raw eigen vectors

Definition at line 277 of file PrincipalComponentAnalysis.cpp.

double GRT::PrincipalComponentAnalysis::getMaxVariance ( ) const
inline

Returns the maxVariance parameter, set by the user when the computeFeatureVector was called. returns the maxVariance parameter, set by the user when the computeFeatureVector was called

Definition at line 141 of file PrincipalComponentAnalysis.h.

VectorDouble GRT::PrincipalComponentAnalysis::getMeanVector ( ) const
inline

Returns the mean shift vector, computed during the computeFeatureVector function. New data will be subtracted by this value before it is projected onto the principal subspace.

Returns
returns the mean shift vector, computed during the computeFeatureVector function

Definition at line 148 of file PrincipalComponentAnalysis.h.

bool GRT::PrincipalComponentAnalysis::getNormData ( ) const
inline

Returns true if z-normalization is being applied to new data.

Returns
returns true if the normData is true, false otherwise

Definition at line 123 of file PrincipalComponentAnalysis.h.

UINT GRT::PrincipalComponentAnalysis::getNumInputDimensions ( ) const
inline

Returns the number of input dimensions in the original input data.

Returns
returns the numInputDimensions parameter.

Definition at line 129 of file PrincipalComponentAnalysis.h.

UINT GRT::PrincipalComponentAnalysis::getNumPrincipalComponents ( ) const
inline

Returns the number of principal components that was required to reach the maxVariance parameter.

Returns
returns the number of principal components that was required to reach the maxVariance parameter

Definition at line 135 of file PrincipalComponentAnalysis.h.

VectorDouble GRT::PrincipalComponentAnalysis::getStdDevVector ( ) const
inline

Returns the standard deviation vector that is used to normalize new data, this is computed during the computeFeatureVector function. This is only used id the normData parameter is true. If true, new data will be z-normalized by this value before it is projected onto the principal subspace.

Returns
returns the stdDev vector, computed during the computeFeatureVector function

Definition at line 156 of file PrincipalComponentAnalysis.h.

bool GRT::PrincipalComponentAnalysis::getTrained ( ) const
inline

Returns true if the module was trained.

Returns
returns true if the module has been trained, false otherwise

Definition at line 117 of file PrincipalComponentAnalysis.h.

bool GRT::PrincipalComponentAnalysis::print ( string  title = "") const
virtual

A helper function that prints the PCA info. If the user sets the title string, then this will be written in addition with the PCA data.

Definition at line 252 of file PrincipalComponentAnalysis.cpp.

bool GRT::PrincipalComponentAnalysis::project ( const MatrixDouble data,
MatrixDouble prjData 
)

Projects the input data matrix onto the principal subspace. The new projected data will be stored in the prjData matrix. The computeFeatureVector function should have been called at least once before this function is called. The number of the columns in the data matrix must match the numInputDimensions parameter. The function will return true if the projection was successful, false otherwise.

Parameters
constMatrixDouble &data: The data that should be projected onto the principal subspace. This should be an [M N] matrix, where N must equal the numInputDimensions value (there are no restrictions on M).
MatrixDouble&prjData: A matrix into which the projected data will be stored. This matrix will be resized to [M K], where M is the number of rows in the data matrix and K is the numPrincipalComponents.
Returns
returns true if the projection was successful, false otherwise

Definition at line 178 of file PrincipalComponentAnalysis.cpp.

bool GRT::PrincipalComponentAnalysis::project ( const VectorDouble &  data,
VectorDouble &  prjData 
)

Projects the input data vector onto the principal subspace. The new projected data will be stored in the prjData vector. The computeFeatureVector function should have been called at least once before this function is called. The size of the data vector must match the numInputDimensions parameter. The function will return true if the projection was successful, false otherwise.

Parameters
constVectorDouble &data: The data that should be projected onto the principal subspace. This should be an N-dimensional vector, where N must equal the numInputDimensions value.
VectorDouble&prjData: A vector into which the projected data will be stored. This vector will be resized to K, where K is the numPrincipalComponents.
Returns
returns true if the projection was successful, false otherwise

Definition at line 216 of file PrincipalComponentAnalysis.cpp.


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