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.
KMeansQuantizer.h
Go to the documentation of this file.
1 
37 #ifndef GRT_KMEANS_QUANTIZER_HEADER
38 #define GRT_KMEANS_QUANTIZER_HEADER
39 
40 //Include the main GRT header to get access to the FeatureExtraction base class
41 #include "../../CoreModules/FeatureExtraction.h"
42 #include "../../ClusteringModules/KMeans/KMeans.h"
43 #include "../../DataStructures/ClassificationDataStream.h"
44 #include "../../DataStructures/TimeSeriesClassificationData.h"
45 #include "../../DataStructures/UnlabelledData.h"
46 
47 GRT_BEGIN_NAMESPACE
48 
49 class GRT_API KMeansQuantizer : public FeatureExtraction{
50 public:
56  KMeansQuantizer(const UINT numClusters=10);
57 
63  KMeansQuantizer(const KMeansQuantizer &rhs);
64 
68  virtual ~KMeansQuantizer();
69 
76  KMeansQuantizer& operator=(const KMeansQuantizer &rhs);
77 
86  virtual bool deepCopyFrom(const FeatureExtraction *featureExtraction);
87 
95  virtual bool computeFeatures(const VectorFloat &inputVector);
96 
103  virtual bool reset();
104 
110  virtual bool clear();
111 
120  virtual bool save( std::fstream &file ) const;
121 
129  virtual bool load( std::fstream &file );
130 
137  virtual bool train_(ClassificationData &trainingData);
138 
145  virtual bool train_(TimeSeriesClassificationData &trainingData);
146 
153  virtual bool train_(ClassificationDataStream &trainingData);
154 
161  virtual bool train_(UnlabelledData &trainingData);
162 
169  virtual bool train_(MatrixFloat &trainingData);
170 
177  UINT quantize(const Float inputValue);
178 
185  UINT quantize(const VectorFloat &inputVector);
186 
192  bool getQuantizerTrained() const { return trained; }
193 
199  UINT getNumClusters() const;
200 
206  UINT getQuantizedValue() const { return (trained ? (UINT)featureVector[0] : 0); }
207 
214  return quantizationDistances;
215  }
216 
224  return clusters;
225  }
226 
232  bool setNumClusters(const UINT numClusters);
233 
234  //Tell the compiler we are using the following functions from the MLBase class to stop hidden virtual function warnings
235  using MLBase::save;
236  using MLBase::load;
237  using MLBase::train_;
238  using MLBase::predict_;
239 
245  static std::string getId();
246 
247 protected:
248  UINT numClusters;
249  MatrixFloat clusters;
250  VectorFloat quantizationDistances;
251 
252 private:
254  static std::string id;
255 };
256 
257 GRT_END_NAMESPACE
258 
259 #endif //GRT_KMEANS_QUANTIZER_HEADER
260 
std::string getId() const
Definition: GRTBase.cpp:85
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:137
virtual bool reset()
Definition: MLBase.cpp:147
MatrixFloat getQuantizationModel() const
UINT getQuantizedValue() const
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 clear() override
bool getQuantizerTrained() const
virtual bool load(const std::string &filename)
Definition: MLBase.cpp:190
virtual bool deepCopyFrom(const FeatureExtraction *rhs)
VectorFloat getQuantizationDistances() const