GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
ContinuousHiddenMarkovModel.h
Go to the documentation of this file.
1 
31 #ifndef GRT_CONTINUOUS_HIDDEN_MARKOV_MODEL_HEADER
32 #define GRT_CONTINUOUS_HIDDEN_MARKOV_MODEL_HEADER
33 
34 #include "HMMEnums.h"
35 #include "../../Util/GRTCommon.h"
36 #include "../../CoreModules/MLBase.h"
37 
38 namespace GRT {
39 
41 public:
42  ContinuousHiddenMarkovModel(const UINT downsampleFactor = 5,const UINT delta = 1,const bool autoEstimateSigma = true,const double sigma = 10.0);
43 
45 
46  virtual ~ContinuousHiddenMarkovModel();
47 
49 
50  virtual bool predict_(VectorDouble &x);
51  virtual bool predict_(MatrixDouble &obs);
52 
53  virtual bool train_(TimeSeriesClassificationSample &trainingData);
54 
62  virtual bool reset();
63 
70  virtual bool clear();
71 
78  virtual bool saveModelToFile(fstream &file) const;
79 
86  virtual bool loadModelFromFile(fstream &file);
87 
88  virtual bool print() const;
89 
90  UINT getNumStates() const { return numStates; }
91 
92  UINT getClassLabel() const { return classLabel; }
93 
94  double getLoglikelihood() const { return loglikelihood; }
95 
96  double getPhase() const { return phase; }
97 
98  vector< UINT > getEstimatedStates() const { return estimatedStates; }
99 
100  MatrixDouble getAlpha() const { return alpha; }
101 
102  bool setDownsampleFactor(const UINT downsampleFactor);
103 
112  bool setModelType(const UINT modelType);
113 
126  bool setDelta(const UINT delta);
127 
128  bool setSigma(const double sigma);
129 
130  bool setAutoEstimateSigma(const bool autoEstimateSigma);
131 
132 protected:
133 
134  double gauss( const MatrixDouble &x, const MatrixDouble &y, const MatrixDouble &sigma, const unsigned int i,const unsigned int j,const unsigned int N );
135 
136  UINT downsampleFactor;
137  UINT numStates;
138  UINT classLabel;
140  bool autoEstimateSigma;
141  double sigma;
142  double phase;
145  VectorDouble pi;
146  MatrixDouble alpha;
147  VectorDouble c;
149  MatrixDouble obsSequence;
150  vector< UINT > estimatedStates;
152 
153  UINT modelType;
154  UINT delta;
155  double loglikelihood;
156  double cThreshold;
157 
158 };
159 
160 }//end of namespace GRT
161 
162 #endif
UINT delta
The number of states a model can move to in a LEFTRIGHT model.
UINT numStates
The number of states for this model.
This class acts as the main interface for using a Hidden Markov Model.
Definition: AdaBoost.cpp:25
double loglikelihood
The log likelihood of an observation sequence given the modal, calculated by the forward method...
CircularBuffer< VectorDouble > observationSequence
A buffer to store data for realtime prediction.
MatrixDouble a
The transitions probability matrix.
virtual bool saveModelToFile(fstream &file) const
double cThreshold
The classification threshold for this model.
UINT classLabel
The class label associated with this model.
UINT modelType
The model type (LEFTRIGHT, or ERGODIC)
VectorDouble pi
The state start probability vector.
UINT timeseriesLength
The length of the training timeseries.
MatrixDouble b
The emissions probability matrix.
MatrixDouble sigmaStates
The sigma value for each state.
vector< UINT > estimatedStates
The estimated states for prediction.