GestureRecognitionToolkit  Version: 0.2.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 
51 class GRT_API PrincipalComponentAnalysis : public MLBase{
52 public:
57 
61  virtual ~PrincipalComponentAnalysis();
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 save( std::fstream &file ) const;
120 
127  virtual bool load( 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 
196  MatrixFloat getEigenVectors() const;
197 
198  bool setModel( const VectorFloat &mean, const MatrixFloat &eigenvectors );
199 
200  //Tell the compiler we are using the base class train method to stop hidden virtual function warnings
201  using MLBase::save;
202  using MLBase::load;
203 
204 protected:
205  bool computeFeatureVector_(const MatrixFloat &data,UINT analysisMode);
206 
207  bool normData;
208  UINT numPrincipalComponents;
209  Float maxVariance;
210  VectorFloat mean;
211  VectorFloat stdDev;
212  VectorFloat componentWeights;
213  VectorFloat eigenvalues;
214  Vector< IndexedDouble > sortedEigenvalues;
215  MatrixFloat eigenvectors;
216 
217  enum AnalysisMode{MAX_VARIANCE=0,MAX_NUM_PCS};
218 };
219 
220 GRT_END_NAMESPACE
221 
222 #endif //GRT_PRINCIPAL_COMPONENT_ANALYSIS_HEADER
virtual bool save(const std::string filename) const
Definition: MLBase.cpp:143
virtual bool load(const std::string filename)
Definition: MLBase.cpp:167
virtual bool print() const
Definition: MLBase.cpp:141
Definition: MLBase.h:70