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.
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 GRT_BEGIN_NAMESPACE
39 
40 class GRT_API ContinuousHiddenMarkovModel : public MLBase {
41  public:
42  ContinuousHiddenMarkovModel(const UINT downsampleFactor = 5,const UINT delta = 1,const bool autoEstimateSigma = true,const Float sigma = 10.0);
43 
45 
46  virtual ~ContinuousHiddenMarkovModel();
47 
49 
50  virtual bool predict_(VectorFloat &x) override;
51  virtual bool predict_(MatrixFloat &obs) override;
52 
53  virtual bool train_(TimeSeriesClassificationSample &trainingData);
54 
62  virtual bool reset() override;
63 
70  virtual bool clear() override;
71 
78  virtual bool save( std::fstream &file ) const override;
79 
86  virtual bool load( std::fstream &file ) override;
87 
88  virtual bool print() const override;
89 
90  UINT getNumStates() const { return numStates; }
91 
92  UINT getClassLabel() const { return classLabel; }
93 
94  Float getLoglikelihood() const { return loglikelihood; }
95 
96  Float getPhase() const { return phase; }
97 
98  Vector< UINT > getEstimatedStates() const { return estimatedStates; }
99 
100  MatrixFloat 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 Float sigma);
129 
130  bool setAutoEstimateSigma(const bool autoEstimateSigma);
131 
132  using MLBase::save;
133  using MLBase::load;
134  using MLBase::train_;
135  using MLBase::predict_;
136 
137 protected:
138 
139  Float gauss( const MatrixFloat &x, const MatrixFloat &y, const MatrixFloat &sigma, const unsigned int i,const unsigned int j,const unsigned int N );
140 
141  UINT downsampleFactor;
142  UINT numStates;
143  UINT classLabel;
145  bool autoEstimateSigma;
146  Float sigma;
147  Float phase;
151  MatrixFloat alpha;
152  VectorFloat c;
154  MatrixFloat obsSequence;
157 
158  UINT modelType;
159  UINT delta;
161  Float cThreshold;
162 
163 };
164 
165 GRT_END_NAMESPACE
166 
167 #endif
virtual bool predict_(VectorFloat &inputVector)
Definition: MLBase.cpp:137
Vector< UINT > estimatedStates
The estimated states for prediction.
virtual bool reset()
Definition: MLBase.cpp:147
Float cThreshold
The classification threshold for this model.
This class acts as the main interface for using a Hidden Markov Model.
MatrixFloat a
The transitions probability matrix.
Float loglikelihood
The log likelihood of an observation sequence given the modal, calculated by the forward method...
VectorFloat pi
The state start probability vector.
UINT modelType
The model type (LEFTRIGHT, or ERGODIC)
virtual bool save(const std::string &filename) const
Definition: MLBase.cpp:167
UINT delta
The number of states a model can move to in a LEFTRIGHT model.
CircularBuffer< VectorFloat > observationSequence
A buffer to store data for realtime prediction.
virtual bool print() const
Definition: MLBase.cpp:165
UINT classLabel
The class label associated with this model.
MatrixFloat sigmaStates
The sigma value for each state.
virtual bool clear()
Definition: MLBase.cpp:149
virtual bool train_(ClassificationData &trainingData)
Definition: MLBase.cpp:109
virtual bool load(const std::string &filename)
Definition: MLBase.cpp:190
MatrixFloat b
The emissions probability matrix.
UINT timeseriesLength
The length of the training timeseries.
This is the main base class that all GRT machine learning algorithms should inherit from...
Definition: MLBase.h:72
UINT numStates
The number of states for this model.