[mlpack-svn] r10283 - mlpack/trunk/src/mlpack/methods/hmm

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Tue Nov 15 14:06:29 EST 2011


Author: rcurtin
Date: 2011-11-15 14:06:29 -0500 (Tue, 15 Nov 2011)
New Revision: 10283

Modified:
   mlpack/trunk/src/mlpack/methods/hmm/hmm.hpp
   mlpack/trunk/src/mlpack/methods/hmm/hmm_impl.hpp
Log:
Comment Estimate() a little better and provide a convenience overload.


Modified: mlpack/trunk/src/mlpack/methods/hmm/hmm.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/hmm/hmm.hpp	2011-11-15 18:36:42 UTC (rev 10282)
+++ mlpack/trunk/src/mlpack/methods/hmm/hmm.hpp	2011-11-15 19:06:29 UTC (rev 10283)
@@ -74,15 +74,42 @@
 
   /**
    * Estimate the probabilities of each hidden state at each time step for each
-   * given data observation.
+   * given data observation, using the Forward-Backward algorithm.  Each matrix
+   * which is returned has columns equal to the number of data observations, and
+   * rows equal to the number of hidden states in the model.  The log-likelihood
+   * of the most probable sequence is returned.
+   *
+   * @param dataSeq Sequence of observations.
+   * @param stateProb Matrix in which the probabilities of each state at each
+   *    time interval will be stored.
+   * @param forwardProb Matrix in which the forward probabilities of each state
+   *    at each time interval will be stored.
+   * @param backwardProb Matrix in which the backward probabilities of each
+   *    state at each time interval will be stored.
+   * @param scales Vector in which the scaling factors at each time interval
+   *    will be stored.
+   * @return Log-likelihood of most likely state sequence.
    */
-  double Estimate(const arma::vec& data_seq,
-                  arma::mat& state_prob_mat,
-                  arma::mat& forward_prob_mat,
-                  arma::mat& backward_prob_mat,
-                  arma::vec& scale_vec) const;
+  double Estimate(const arma::vec& dataSeq,
+                  arma::mat& stateProb,
+                  arma::mat& forwardProb,
+                  arma::mat& backwardProb,
+                  arma::vec& scales) const;
 
   /**
+   * Estimate the probabilities of each hidden state at each time step of each
+   * given data observation, using the Forward-Backward algorithm.  The returned
+   * matrix of state probabilities has columns equal to the number of data
+   * observations, and rows equal to the number of hidden states in the model.
+   * The log-likelihood of the most probable sequence is returned.
+   *
+   * @param dataSeq Sequence of observations.
+   * @param stateProb Probabilities of each state at each time interval.
+   * @return Log-likelihood of most likely state sequence.
+   */
+  double Estimate(const arma::vec& dataSeq, arma::mat& stateProb) const;
+
+  /**
    * Generate a random data sequence of the given length.  The data sequence is
    * stored in the data_sequence parameter, and the state sequence is stored in
    * the state_sequence parameter.

Modified: mlpack/trunk/src/mlpack/methods/hmm/hmm_impl.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/hmm/hmm_impl.hpp	2011-11-15 18:36:42 UTC (rev 10282)
+++ mlpack/trunk/src/mlpack/methods/hmm/hmm_impl.hpp	2011-11-15 19:06:29 UTC (rev 10283)
@@ -200,6 +200,21 @@
 }
 
 /**
+ * Estimate the probabilities of each hidden state at each time step for each
+ * given data observation.
+ */
+template<typename Distribution>
+double HMM<Distribution>::Estimate(const arma::vec& dataSeq,
+                                   arma::mat& stateProb) const
+{
+  // We don't need to save these.
+  arma::mat forwardProb, backwardProb;
+  arma::vec scales;
+
+  return Estimate(dataSeq, stateProb, forwardProb, backwardProb, scales);
+}
+
+/**
  * Generate a random data sequence of a given length.  The data sequence is
  * stored in the dataSequence parameter, and the state sequence is stored in
  * the stateSequence parameter.




More information about the mlpack-svn mailing list