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.
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 
50 public:
56  KMeansQuantizer(const UINT numClusters=10);
57 
63  KMeansQuantizer(const KMeansQuantizer &rhs);
64 
68  virtual ~KMeansQuantizer();
69 
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 saveModelToFile( std::fstream &file ) const;
121 
129  virtual bool loadModelFromFile( 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(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 FeatureExtractiona and MLBase class to stop hidden virtual function warnings
237  using MLBase::train;
238  using MLBase::train_;
239  using MLBase::predict;
240  using MLBase::predict_;
241 
242 protected:
243  UINT numClusters;
244  MatrixFloat clusters;
245  VectorFloat quantizationDistances;
246 
248 };
249 
250 GRT_END_NAMESPACE
251 
252 #endif //GRT_KMEANS_QUANTIZER_HEADER
virtual bool train_(ClassificationData &trainingData)
virtual bool computeFeatures(const VectorFloat &inputVector)
virtual bool reset()
virtual bool predict(VectorFloat inputVector)
Definition: MLBase.cpp:112
KMeansQuantizer(const UINT numClusters=10)
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:114
MatrixFloat getQuantizationModel() const
virtual bool saveModelToFile(std::fstream &file) const
UINT getQuantizedValue() const
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:88
virtual bool loadModelFromFile(std::fstream &file)
virtual bool deepCopyFrom(const FeatureExtraction *featureExtraction)
virtual bool saveModelToFile(std::fstream &file) const
bool setNumClusters(const UINT numClusters)
UINT quantize(Float inputValue)
UINT getNumClusters() const
virtual bool clear()
virtual ~KMeansQuantizer()
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:90
KMeansQuantizer & operator=(const KMeansQuantizer &rhs)
virtual bool loadModelFromFile(std::fstream &file)
bool getQuantizerTrained() const
VectorFloat getQuantizationDistances() const