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.
PrincipalComponentAnalysis.h
Go to the documentation of this file.
1 
43 #ifndef GRT_PRINCIPAL_COMPONENT_ANALYSIS_HEADER
44 #define GRT_PRINCIPAL_COMPONENT_ANALYSIS_HEADER
45 
46 #include "../../Util/GRTCommon.h"
47 #include "../../CoreModules/MLBase.h"
48 
49 GRT_BEGIN_NAMESPACE
50 
52  public:
57 
62 
76  bool computeFeatureVector(const MatrixFloat &data,Float maxVariance=0.95,bool normData=false);
77 
89  bool computeFeatureVector(const MatrixFloat &data,UINT numPrincipalComponents,bool normData=false);
90 
100  bool project(const MatrixFloat &data,MatrixFloat &prjData);
101 
111  bool project(const VectorFloat &data,VectorFloat &prjData);
112 
119  virtual bool saveModelToFile( std::fstream &file ) const;
120 
127  virtual bool loadModelFromFile( std::fstream &file );
128 
133  bool getTrained() const { return trained; }
134 
139  bool getNormData() const { return normData; }
140 
145  UINT getNumInputDimensions() const { return numInputDimensions; }
146 
151  UINT getNumPrincipalComponents() const { return numPrincipalComponents; }
152 
157  Float getMaxVariance() const { return maxVariance; }
158 
164  VectorFloat getMeanVector() const { return mean; }
165 
172  VectorFloat getStdDevVector() const { return stdDev; }
173 
178  VectorFloat getComponentWeights() const { return componentWeights; }
179 
184  VectorFloat getEigenValues() const { return eigenvalues; }
185 
190  virtual bool print( std::string title="" ) const;
191 
197 
198  bool setModel( const VectorFloat &mean, const MatrixFloat &eigenvectors );
199 
200 protected:
201  bool computeFeatureVector_(const MatrixFloat &data,UINT analysisMode);
202 
203  bool normData;
204  UINT numPrincipalComponents;
205  Float maxVariance;
206  VectorFloat mean;
207  VectorFloat stdDev;
208  VectorFloat componentWeights;
209  VectorFloat eigenvalues;
210  Vector< IndexedDouble > sortedEigenvalues;
211  MatrixFloat eigenvectors;
212 
213  enum AnalysisMode{MAX_VARIANCE=0,MAX_NUM_PCS};
214 
215 };
216 
217 GRT_END_NAMESPACE
218 
219 #endif //GRT_PRINCIPAL_COMPONENT_ANALYSIS_HEADER
220 
221 
virtual bool loadModelFromFile(std::fstream &file)
virtual bool saveModelToFile(std::fstream &file) const
virtual bool print() const
Definition: MLBase.cpp:140
bool project(const MatrixFloat &data, MatrixFloat &prjData)
bool computeFeatureVector(const MatrixFloat &data, Float maxVariance=0.95, bool normData=false)
Definition: MLBase.h:70