mlpack  2.0.1
hmm_regression.hpp
Go to the documentation of this file.
1 
14 #ifndef __MLPACK_METHODS_HMM_HMM_REGRESSION_HPP
15 #define __MLPACK_METHODS_HMM_HMM_REGRESSION_HPP
16 
17 #include <mlpack/core.hpp>
19 #include "hmm.hpp"
20 
21 namespace mlpack {
22 namespace hmm {
23 
71 class HMMRegression : public HMM<distribution::RegressionDistribution>
72 {
73  public:
91  HMMRegression(const size_t states,
93  const double tolerance = 1e-5) :
94  HMM<distribution::RegressionDistribution>(states, emissions, tolerance)
95  { /* nothing to do */ }
96 
121  HMMRegression(const arma::vec& initial,
122  const arma::mat& transition,
123  const std::vector<distribution::RegressionDistribution>& emission,
124  const double tolerance = 1e-5) :
125  HMM<distribution::RegressionDistribution>(initial, transition, emission,
126  tolerance)
127  { /* nothing to do */ }
128 
129 
130 
160  void Train(const std::vector<arma::mat>& predictors,
161  const std::vector<arma::vec>& responses);
162 
182  void Train(const std::vector<arma::mat>& predictors,
183  const std::vector<arma::vec>& responses,
184  const std::vector<arma::Row<size_t> >& stateSeq);
185 
205  double Estimate(const arma::mat& predictors,
206  const arma::vec& responses,
207  arma::mat& stateProb,
208  arma::mat& forwardProb,
209  arma::mat& backwardProb,
210  arma::vec& scales) const;
211 
224  double Estimate(const arma::mat& predictors,
225  const arma::vec& responses,
226  arma::mat& stateProb) const;
227 
239  double Predict(const arma::mat& predictors,
240  const arma::vec& responses,
241  arma::Row<size_t>& stateSeq) const;
242 
250  double LogLikelihood(const arma::mat& predictors,
251  const arma::vec& responses) const;
266  void Filter(const arma::mat& predictors,
267  const arma::vec& responses,
268  arma::vec& filterSeq,
269  size_t ahead = 0) const;
270 
284  void Smooth(const arma::mat& predictors,
285  const arma::vec& responses,
286  arma::vec& smoothSeq) const;
287 
288  private:
292  void StackData(const std::vector<arma::mat>& predictors,
293  const std::vector<arma::vec>& responses,
294  std::vector<arma::mat>& dataSeq) const;
295 
296  void StackData(const arma::mat& predictors,
297  const arma::vec& responses,
298  arma::mat& dataSeq) const;
299 
311  void Forward(const arma::mat& predictors,
312  const arma::vec& responses,
313  arma::vec& scales,
314  arma::mat& forwardProb) const;
315 
328  void Backward(const arma::mat& predictors,
329  const arma::vec& responses,
330  const arma::vec& scales,
331  arma::mat& backwardProb) const;
332 
333 
334 };
335 
336 } // namespace hmm
337 } // namespace mlpack
338 
339 // Include implementation.
340 #include "hmm_regression_impl.hpp"
341 
342 #endif
std::vector< distribution::RegressionDistribution > emission
Set of emission probability distributions; one for each state.
Definition: hmm.hpp:364
HMMRegression(const arma::vec &initial, const arma::mat &transition, const std::vector< distribution::RegressionDistribution > &emission, const double tolerance=1e-5)
Create the Hidden Markov Model Regression with the given initial probability vector, the given transition matrix, and the given regression emission distributions.
Linear algebra utility functions, generally performed on matrices or vectors.
A class that represents a Hidden Markov Model Regression (HMMR).
double tolerance
Tolerance of Baum-Welch algorithm.
Definition: hmm.hpp:377
void Backward(const arma::mat &predictors, const arma::vec &responses, const arma::vec &scales, arma::mat &backwardProb) const
The Backward algorithm (part of the Forward-Backward algorithm).
arma::vec initial
Initial state probability vector.
Definition: hmm.hpp:371
A class that represents a univariate conditionally Gaussian distribution.
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
double LogLikelihood(const arma::mat &predictors, const arma::vec &responses) const
Compute the log-likelihood of the given predictors and responses.
A class that represents a Hidden Markov Model with an arbitrary type of emission distribution.
Definition: hmm.hpp:86
void Smooth(const arma::mat &predictors, const arma::vec &responses, arma::vec &smoothSeq) const
HMM smoothing.
void StackData(const std::vector< arma::mat > &predictors, const std::vector< arma::vec > &responses, std::vector< arma::mat > &dataSeq) const
Utility functions to facilitate the use of the HMM class for HMMR.
void Forward(const arma::mat &predictors, const arma::vec &responses, arma::vec &scales, arma::mat &forwardProb) const
The Forward algorithm (part of the Forward-Backward algorithm).
void Filter(const arma::mat &predictors, const arma::vec &responses, arma::vec &filterSeq, size_t ahead=0) const
HMMR filtering.
double Estimate(const arma::mat &predictors, const arma::vec &responses, arma::mat &stateProb, arma::mat &forwardProb, arma::mat &backwardProb, arma::vec &scales) const
Estimate the probabilities of each hidden state at each time step for each given data observation...
HMMRegression(const size_t states, const distribution::RegressionDistribution emissions, const double tolerance=1e-5)
Create the Hidden Markov Model Regression with the given number of hidden states and the given defaul...
void Train(const std::vector< arma::mat > &predictors, const std::vector< arma::vec > &responses)
Train the model using the Baum-Welch algorithm, with only the given predictors and responses...
double Predict(const arma::mat &predictors, const arma::vec &responses, arma::Row< size_t > &stateSeq) const
Compute the most probable hidden state sequence for the given predictors and responses, using the Viterbi algorithm, returning the log-likelihood of the most likely state sequence.
arma::mat transition
Transition probability matrix.
Definition: hmm.hpp:367