mlpack 3.4.2
hmm_regression.hpp
Go to the documentation of this file.
1
12#ifndef MLPACK_METHODS_HMM_HMM_REGRESSION_HPP
13#define MLPACK_METHODS_HMM_HMM_REGRESSION_HPP
14
15#include <mlpack/prereqs.hpp>
17#include "hmm.hpp"
18
19namespace mlpack {
20namespace hmm {
21
69class HMMRegression : public HMM<distribution::RegressionDistribution>
70{
71 public:
89 HMMRegression(const size_t states,
91 const double tolerance = 1e-5) :
92 HMM<distribution::RegressionDistribution>(states, emissions, tolerance)
93 { /* nothing to do */ }
94
119 HMMRegression(const arma::vec& initial,
120 const arma::mat& transition,
121 const std::vector<distribution::RegressionDistribution>& emission,
122 const double tolerance = 1e-5) :
123 HMM<distribution::RegressionDistribution>(initial, transition, emission,
124 tolerance)
125 { /* nothing to do */ }
126
127
128
157 void Train(const std::vector<arma::mat>& predictors,
158 const std::vector<arma::vec>& responses);
159
178 void Train(const std::vector<arma::mat>& predictors,
179 const std::vector<arma::vec>& responses,
180 const std::vector<arma::Row<size_t> >& stateSeq);
181
201 double Estimate(const arma::mat& predictors,
202 const arma::vec& responses,
203 arma::mat& stateProb,
204 arma::mat& forwardProb,
205 arma::mat& backwardProb,
206 arma::vec& scales) const;
207
220 double Estimate(const arma::mat& predictors,
221 const arma::vec& responses,
222 arma::mat& stateProb) const;
223
235 double Predict(const arma::mat& predictors,
236 const arma::vec& responses,
237 arma::Row<size_t>& stateSeq) const;
238
246 double LogLikelihood(const arma::mat& predictors,
247 const arma::vec& responses) const;
261 void Filter(const arma::mat& predictors,
262 const arma::vec& responses,
263 arma::vec& filterSeq,
264 size_t ahead = 0) const;
265
278 void Smooth(const arma::mat& predictors,
279 const arma::vec& responses,
280 arma::vec& smoothSeq) const;
281
282 private:
286 void StackData(const std::vector<arma::mat>& predictors,
287 const std::vector<arma::vec>& responses,
288 std::vector<arma::mat>& dataSeq) const;
289
290 void StackData(const arma::mat& predictors,
291 const arma::vec& responses,
292 arma::mat& dataSeq) const;
293
305 void Forward(const arma::mat& predictors,
306 const arma::vec& responses,
307 arma::vec& scales,
308 arma::mat& forwardProb) const;
309
322 void Backward(const arma::mat& predictors,
323 const arma::vec& responses,
324 const arma::vec& scales,
325 arma::mat& backwardProb) const;
326};
327
328} // namespace hmm
329} // namespace mlpack
330
331// Include implementation.
332#include "hmm_regression_impl.hpp"
333
334#endif
A class that represents a univariate conditionally Gaussian distribution.
A class that represents a Hidden Markov Model Regression (HMMR).
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,...
double Estimate(const arma::mat &predictors, const arma::vec &responses, arma::mat &stateProb) const
Estimate the probabilities of each hidden state at each time step of each given data observation,...
void Filter(const arma::mat &predictors, const arma::vec &responses, arma::vec &filterSeq, size_t ahead=0) const
HMMR filtering.
void Smooth(const arma::mat &predictors, const arma::vec &responses, arma::vec &smoothSeq) const
HMM smoothing.
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,...
double LogLikelihood(const arma::mat &predictors, const arma::vec &responses) const
Compute the log-likelihood of the given predictors and responses.
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,...
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, const std::vector< arma::Row< size_t > > &stateSeq)
Train the model using the given labeled observations; the transition and regression emissions are dir...
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.
A class that represents a Hidden Markov Model with an arbitrary type of emission distribution.
Definition: hmm.hpp:86
std::vector< distribution::RegressionDistribution > emission
Set of emission probability distributions; one for each state.
Definition: hmm.hpp:403
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.