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.
HMM.h
Go to the documentation of this file.
1 
26 #ifndef GRT_HMM_HEADER
27 #define GRT_HMM_HEADER
28 
29 #include "HMMEnums.h"
32 #include "../../CoreModules/Classifier.h"
33 
34 GRT_BEGIN_NAMESPACE
35 
41 class GRT_API HMM : public Classifier
42 {
43 public:
55  HMM(const UINT hmmType=HMM_CONTINUOUS,const UINT modelType=HMM_LEFTRIGHT,const UINT delta=1,const bool useScaling = false,const bool useNullRejection = false);
56 
64  HMM(const HMM &rhs);
65 
69  virtual ~HMM(void);
70 
79  HMM& operator=(const HMM &rhs);
80 
88  virtual bool deepCopyFrom(const Classifier *classifier);
89 
97  virtual bool train(ClassificationData trainingData);
98 
107  virtual bool train_(TimeSeriesClassificationData &trainingData);
108 
116  virtual bool predict_(VectorFloat &inputVector);
117 
125  virtual bool predict_(MatrixFloat &timeseries);
126 
132  virtual bool reset();
133 
140  virtual bool clear();
141 
142  virtual bool print() const;
143 
151  virtual bool save( std::fstream &file ) const;
152 
160  virtual bool load( std::fstream &file );
161 
167  UINT getHMMType() const;
168 
174  UINT getModelType() const;
175 
182  UINT getDelta() const;
183 
189  UINT getNumStates() const;
190 
196  UINT getNumSymbols() const;
197 
208  UINT getNumRandomTrainingIterations() const;
209 
216  Vector< DiscreteHiddenMarkovModel > getDiscreteModels() const;
217 
224  Vector< ContinuousHiddenMarkovModel > getContinuousModels() const;
225 
234  bool setHMMType(const UINT hmmType);
235 
244  bool setModelType(const UINT modelType);
245 
258  bool setDelta(const UINT delta);
259 
271  bool setDownsampleFactor(const UINT downsampleFactor);
272 
282  bool setCommitteeSize(const UINT committeeSize);
283 
292  bool setNumStates(const UINT numStates);
293 
300  bool setNumSymbols(const UINT numStates);
301 
314  bool setNumRandomTrainingIterations(const UINT numRandomTrainingIterations);
315 
328  bool setSigma(const Float sigma);
329 
330  bool setAutoEstimateSigma(const bool autoEstimateSigma);
331 
337  static std::string getId();
338 
339  //Tell the compiler we are using the base class train method to stop hidden virtual function warnings
340  using MLBase::save;
341  using MLBase::load;
342  using MLBase::train;
343  using MLBase::train_;
344  using MLBase::predict_;
345 
346 protected:
347  bool train_discrete(TimeSeriesClassificationData &trainingData);
348  bool train_continuous(TimeSeriesClassificationData &trainingData);
349  bool predict_discrete( VectorFloat &inputVector );
350  bool predict_continuous( VectorFloat &inputVector );
351  bool predict_discrete(MatrixFloat &timeseries);
352  bool predict_continuous(MatrixFloat &timeseries);
353  bool convertDataToObservationSequence( TimeSeriesClassificationData &classData, Vector< Vector< UINT > > &observationSequences );
354  bool loadLegacyModelFromFile( std::fstream &file );
355 
356  UINT hmmType;
357  UINT modelType; //Set if the model is ERGODIC or LEFTRIGHT
358  UINT delta; //The number of states a model can move to in a LeftRight model
359 
360  //Discrete HMM variables
361  UINT numStates; //The number of states for each model
362  UINT numSymbols; //The number of symbols for each model
363  UINT numRandomTrainingIterations;
365 
366  //Continuous HMM variables
367  UINT downsampleFactor;
368  UINT committeeSize;
369  Float sigma;
370  bool autoEstimateSigma;
371  Vector< ContinuousHiddenMarkovModel > continuousModels;
372 
373 private:
374  static RegisterClassifierModule< HMM > registerModule;
375  static const std::string id;
376 };
377 
378 GRT_END_NAMESPACE
379 
380 #endif //GRT_HMM_HEADER
std::string getId() const
Definition: GRTBase.cpp:85
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:137
This class acts as the main interface for using a Hidden Markov Model.
virtual bool train(ClassificationData trainingData)
Definition: MLBase.cpp:107
virtual bool save(const std::string &filename) const
Definition: MLBase.cpp:167
UINT hmmType
Controls if this is a HMM_DISCRETE or a HMM_CONTINUOUS.
Definition: HMM.h:356
virtual bool deepCopyFrom(const Classifier *classifier)
Definition: Classifier.h:64
virtual bool print() const
Definition: MLBase.cpp:165
This class implements a continuous Hidden Markov Model.
virtual bool reset()
Definition: Classifier.cpp:132
This class acts as the main interface for using a Hidden Markov Model.
Definition: HMM.h:41
This class implements a discrete Hidden Markov Model.
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:109
virtual bool load(const std::string &filename)
Definition: MLBase.cpp:190
virtual bool clear()
Definition: Classifier.cpp:151
This is the main base class that all GRT Classification algorithms should inherit from...
Definition: Classifier.h:41