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.
KMeansFeatures.h
Go to the documentation of this file.
1 
29 #ifndef GRT_KMEANS_FEATURES_HEADER
30 #define GRT_KMEANS_FEATURES_HEADER
31 
32 //Include the main GRT header to get access to the FeatureExtraction base class
33 #include "../../CoreModules/FeatureExtraction.h"
34 #include "../../ClusteringModules/KMeans/KMeans.h"
35 #include "../../DataStructures/TimeSeriesClassificationData.h"
36 #include "../../DataStructures/ClassificationDataStream.h"
37 #include "../../DataStructures/UnlabelledData.h"
38 
39 GRT_BEGIN_NAMESPACE
40 
42 public:
49  KMeansFeatures(const Vector< UINT > numClustersPerLayer = Vector< UINT >(1,100),const Float alpha = 0.2,const bool useScaling = true);
50 
56  KMeansFeatures(const KMeansFeatures &rhs);
57 
61  virtual ~KMeansFeatures();
62 
70 
79  virtual bool deepCopyFrom(const FeatureExtraction *featureExtraction);
80 
89  virtual bool computeFeatures(const VectorFloat &inputVector);
90 
98  virtual bool reset();
99 
106  virtual bool saveModelToFile( std::string filename ) const;
107 
114  virtual bool loadModelFromFile( std::string filename );
115 
124  virtual bool saveModelToFile( std::fstream &file ) const;
125 
133  virtual bool loadModelFromFile( std::fstream &file );
134 
141  virtual bool train_(ClassificationData &trainingData);
142 
149  virtual bool train_(TimeSeriesClassificationData &trainingData);
150 
157  virtual bool train_(ClassificationDataStream &trainingData);
158 
165  virtual bool train_(UnlabelledData &trainingData);
166 
173  virtual bool train_(MatrixFloat &trainingData);
174 
175  bool computeFeatures(VectorFloat &inputVector,VectorFloat &outputVector);
176 
177  bool init( const Vector< UINT > numClustersPerLayer );
178 
179  bool projectDataThroughLayer( const VectorFloat &input, VectorFloat &output, const UINT layer );
180 
181  UINT getNumLayers() const;
182  UINT getLayerSize(const UINT layerIndex) const;
183  Vector< MatrixFloat > getClusters() const;
184 
185  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
186  using MLBase::train;
187  using MLBase::train_;
188  using MLBase::predict;
189  using MLBase::predict_;
190 
191 protected:
192  Float alpha;
193  Vector< UINT > numClustersPerLayer;
194  Vector< MinMax > ranges;
195  Vector< MatrixFloat > clusters;
196 
198 };
199 
200 GRT_END_NAMESPACE
201 
202 #endif //GRT_KMEANS_FEATURES_HEADER
virtual bool predict(VectorFloat inputVector)
Definition: MLBase.cpp:112
KMeansFeatures(const Vector< UINT > numClustersPerLayer=Vector< UINT >(1, 100), const Float alpha=0.2, const bool useScaling=true)
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:114
virtual bool deepCopyFrom(const FeatureExtraction *featureExtraction)
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:88
virtual bool train_(ClassificationData &trainingData)
virtual bool computeFeatures(const VectorFloat &inputVector)
KMeansFeatures & operator=(const KMeansFeatures &rhs)
virtual bool loadModelFromFile(std::string filename)
virtual ~KMeansFeatures()
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:90
virtual bool reset()
virtual bool saveModelToFile(std::string filename) const