[mlpack-git] master: Implementation of HMM Regression (e9fddfc)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:00:13 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

>---------------------------------------------------------------

commit e9fddfc0825fb0fe2b6c8d9167d59491bde33263
Author: michaelfox99 <michaelfox99 at gmail.com>
Date:   Sat Sep 13 15:21:09 2014 +0000

    Implementation of HMM Regression


>---------------------------------------------------------------

e9fddfc0825fb0fe2b6c8d9167d59491bde33263
 src/mlpack/core/dists/hmm_regression_impl.hpp | 64 +++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/src/mlpack/core/dists/hmm_regression_impl.hpp b/src/mlpack/core/dists/hmm_regression_impl.hpp
new file mode 100644
index 0000000..950e4e2
--- /dev/null
+++ b/src/mlpack/core/dists/hmm_regression_impl.hpp
@@ -0,0 +1,64 @@
+/**
+ * @file hmm_regression_impl.hpp
+ * @author Michael Fox
+ *
+ * Implementation of conditional Gaussian distribution for HMM regression (HMMR)
+ */
+#ifndef __MLPACK_METHODS_HMM_DISTRIBUTIONS_CONDITIONAL_GAUSSIAN_DISTRIBUTION_IMPL_HPP
+#define __MLPACK_METHODS_HMM_DISTRIBUTIONS_CONDITIONAL_GAUSSIAN_DISTRIBUTION_IMPL_HPP
+
+#include "hmm_regression.hpp"
+
+using namespace mlpack;
+using namespace mlpack::distribution;
+
+/**
+ * Returns a string representation of this object.
+ */
+std::string HMMRegression::ToString()
+    const
+{
+  std::ostringstream convert;
+  convert << "HMMRegression [" << this << "]" << std::endl;
+
+  // Secondary ostringstream so things can be indented right.
+  std::ostringstream data;
+  data << "Conditional mean function: " << std::endl << rf.ToString();
+  data << "Parameters: " << std::endl << rf.Parameters();
+  data << "Error distribution: " << std::endl << err.ToString();
+
+  convert << util::Indent(data.str());
+  return convert.str();
+}
+
+/**
+* Estimate parameters using provided observation weights
+*
+* @param weights probability that given observation is from distribution
+*/
+void HMMRegression::Estimate(const arma::mat& observations,
+                             const arma::vec& weights)
+{
+  regression::LinearRegression lr(observations.rows(1, observations.n_rows-1),
+      (observations.row(0)).t(), 0, true, weights);
+  rf = lr;
+  arma::vec fitted;
+  lr.Predict(observations.rows(1, observations.n_rows-1), fitted);
+  err.Estimate(observations.row(0)-fitted.t(), weights);
+}
+
+/**
+* Evaluate probability density function of given observation  
+*
+* @param observation point to evaluate probability at
+*/
+double HMMRegression::Probability(const arma::vec& observation) const
+{
+  arma::vec fitted;
+  rf.Predict(observation.rows(1, observation.n_rows-1), fitted);
+  return err.Probability(observation(0)-fitted);
+}
+
+
+
+#endif
\ No newline at end of file



More information about the mlpack-git mailing list