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.
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 
41 class GRT_API KMeansFeatures : public FeatureExtraction{
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 
69  KMeansFeatures& operator=(const KMeansFeatures &rhs);
70 
79  virtual bool deepCopyFrom(const FeatureExtraction *featureExtraction) override;
80 
89  virtual bool computeFeatures(const VectorFloat &inputVector) override;
90 
98  virtual bool reset() override;
99 
108  virtual bool save( std::fstream &file ) const override;
109 
117  virtual bool load( std::fstream &file ) override;
118 
125  virtual bool train_(ClassificationData &trainingData) override;
126 
133  virtual bool train_(TimeSeriesClassificationData &trainingData) override;
134 
141  virtual bool train_(ClassificationDataStream &trainingData) override;
142 
149  virtual bool train_(UnlabelledData &trainingData) override;
150 
157  virtual bool train_(MatrixFloat &trainingData) override;
158 
159  bool init( const Vector< UINT > &numClustersPerLayer );
160 
161  bool projectDataThroughLayer( const VectorFloat &input, VectorFloat &output, const UINT layer );
162 
163  UINT getNumLayers() const;
164  UINT getLayerSize(const UINT layerIndex) const;
165  Vector< MatrixFloat > getClusters() const;
166 
167  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
168  using MLBase::save;
169  using MLBase::load;
170  using MLBase::train;
171  using MLBase::train_;
172  using MLBase::predict;
173  using MLBase::predict_;
174 
180  static std::string getId();
181 
182 protected:
183  Float alpha;
184  Vector< UINT > numClustersPerLayer;
185  Vector< MinMax > ranges;
186  Vector< MatrixFloat > clusters;
187 
188 private:
190  static std::string id;
191 };
192 
193 GRT_END_NAMESPACE
194 
195 #endif //GRT_KMEANS_FEATURES_HEADER
std::string getId() const
Definition: GRTBase.cpp:85
virtual bool predict(VectorFloat inputVector)
Definition: MLBase.cpp:135
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:137
virtual bool reset()
Definition: MLBase.cpp:147
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:107
virtual bool save(const std::string &filename) const
Definition: MLBase.cpp:167
virtual bool computeFeatures(const VectorFloat &inputVector)
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:109
virtual bool load(const std::string &filename)
Definition: MLBase.cpp:190
virtual bool deepCopyFrom(const FeatureExtraction *rhs)