[mlpack] 06/149: Implementation of HMM Regression

Barak A. Pearlmutter barak+git at pearlmutter.net
Sat May 2 09:11:03 UTC 2015


This is an automated email from the git hooks/post-receive script.

bap pushed a commit to branch svn-trunk
in repository mlpack.

commit 46b7cb28f6c2eb4ad2b7b4901033e11a2655c8d7
Author: michaelfox99 <michaelfox99 at 9d5b8971-822b-0410-80eb-d18c1038ef23>
Date:   Sat Sep 13 15:21:09 2014 +0000

    Implementation of HMM Regression
    
    
    git-svn-id: http://svn.cc.gatech.edu/fastlab/mlpack/trunk@17179 9d5b8971-822b-0410-80eb-d18c1038ef23
---
 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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/mlpack.git



More information about the debian-science-commits mailing list