GestureRecognitionToolkit  Version: 0.2.5
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 
27 #ifndef GRT_PRINCIPAL_COMPONENT_ANALYSIS_HEADER
28 #define GRT_PRINCIPAL_COMPONENT_ANALYSIS_HEADER
29 
30 #include "../../Util/GRTCommon.h"
31 #include "../../CoreModules/MLBase.h"
32 
33 GRT_BEGIN_NAMESPACE
34 
52 class GRT_API PrincipalComponentAnalysis : public MLBase{
53 public:
58 
62  virtual ~PrincipalComponentAnalysis();
63 
77  bool computeFeatureVector(const MatrixFloat &data,Float maxVariance=0.95,bool normData=false);
78 
90  bool computeFeatureVector(const MatrixFloat &data,UINT numPrincipalComponents,bool normData=false);
91 
101  bool project(const MatrixFloat &data,MatrixFloat &prjData);
102 
112  bool project(const VectorFloat &data,VectorFloat &prjData);
113 
120  virtual bool save( std::fstream &file ) const;
121 
128  virtual bool load( std::fstream &file );
129 
134  bool getNormData() const { return normData; }
135 
140  UINT getNumInputDimensions() const { return numInputDimensions; }
141 
146  UINT getNumPrincipalComponents() const { return numPrincipalComponents; }
147 
152  Float getMaxVariance() const { return maxVariance; }
153 
159  VectorFloat getMeanVector() const { return mean; }
160 
167  VectorFloat getStdDevVector() const { return stdDev; }
168 
173  VectorFloat getComponentWeights() const { return componentWeights; }
174 
179  VectorFloat getEigenValues() const { return eigenvalues; }
180 
185  virtual bool print( std::string title="" ) const;
186 
191  MatrixFloat getEigenVectors() const;
192 
193  bool setModel( const VectorFloat &mean, const MatrixFloat &eigenvectors );
194 
195  //Tell the compiler we are using the base class train method to stop hidden virtual function warnings
196  using MLBase::save;
197  using MLBase::load;
198  using MLBase::print;
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 GRT_END_NAMESPACE
217 
218 #endif //GRT_PRINCIPAL_COMPONENT_ANALYSIS_HEADER
virtual bool save(const std::string &filename) const
Definition: MLBase.cpp:167
virtual bool print() const
Definition: MLBase.cpp:165
This class runs the Principal Component Analysis (PCA) algorithm, a dimensionality reduction algorith...
virtual bool load(const std::string &filename)
Definition: MLBase.cpp:190
This is the main base class that all GRT machine learning algorithms should inherit from...
Definition: MLBase.h:72