[mlpack-svn] r10778 - mlpack/trunk/src/mlpack/methods/gmm

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Dec 14 08:15:40 EST 2011


Author: rcurtin
Date: 2011-12-14 08:15:40 -0500 (Wed, 14 Dec 2011)
New Revision: 10778

Removed:
   mlpack/trunk/src/mlpack/methods/gmm/README.txt
Modified:
   mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp
   mlpack/trunk/src/mlpack/methods/gmm/phi.hpp
Log:
Documentation fixes for GMMs and removal of now-unnecessary README.


Deleted: mlpack/trunk/src/mlpack/methods/gmm/README.txt
===================================================================
--- mlpack/trunk/src/mlpack/methods/gmm/README.txt	2011-12-14 13:15:13 UTC (rev 10777)
+++ mlpack/trunk/src/mlpack/methods/gmm/README.txt	2011-12-14 13:15:40 UTC (rev 10778)
@@ -1,39 +0,0 @@
-Author: Parikshit Ram (pram at cc.gatech.edu)
-
-The files are the following:
-1. mog_em_main.cc - this is the main which creates an object of the class MoGEM, initializes it, and then does parametric estimation on the data input using the L2 error criteria. The executable formed is called "mog_em_main".
- - parameters input to the main:
-  --data : this is the file containing the data on which the mixture of gaussians is supposed to be fit.
-  --mog_em/K : the number of gaussians you want to fit on the data
-
-2. mog_em.h - this is the file that contains the definition of the class MoGEM and the function tht implements the EM algorithm.
-
-3. mog_em.cc - this contains definition of some of the functions that are only declared in mog_em.h
-
-4. mog_l2e_main.cc - this is the main which creates an object of the class MoGL2E, initializes it, and then does parametric estimation on the data input using the L2 error criteria. The executable formed is called "mog_l2e_main".
- - parameters input to the main:
-  --data : this is the file containing the data on which the mixture of gaussians is supposed to be fit.
-  --mog_l2e/K : the number of gaussians you want to fit on the data
-  --opt/method : this lets the user choose which optimizer he/she wants to use. It is 'NelderMead' for the polytope method, otherwise it defaults to 'QuasiNewton' for the quasi newton method.
-  --output : the file into which the estimated parameters of the gaussian mixture are written into, defaults to "output.csv" (the output is in the "pretty-print" format)
-
-5. mog_l2e.h - this is the file that contains the definition of the class MoGL2E and computes the L2 error of the present model.
-
-6. mog_l2e.cc - this contains definition of some of the functions that are only declared in mog.h
-
-7. phi.h - this contains the functions that calculates the value of the multivariate Gaussian PDF, and also the gradients of the gaussian PDF with respect to the mean and variance when d(sigma) is provided.
-
-8. math_functions.h - this file contains functions that output the highest/lowest elements in an array and/or their indices.
-
-9. build.py
-
-10. The .arff file - the data files on which you can run the program.
-
--> An example run would be:
-fl-build mog_em_main
-./mog_em_main --data=fake.arff --mog_em/K=3 
-
-fl-build mog_l2e_main
-./mog_l2e_main --data=fake.arff --mog_l2e/K=3 --opt/method=NelderMead
-OR
-./mog_l2e_main --data=fake.arff --mog_l2e/K=3 --opt/method=QuasiNewton

Modified: mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp	2011-12-14 13:15:13 UTC (rev 10777)
+++ mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp	2011-12-14 13:15:40 UTC (rev 10778)
@@ -11,24 +11,29 @@
 #include <mlpack/core.hpp>
 
 namespace mlpack {
-namespace gmm {
+namespace gmm /*** Gaussian Mixture Models. */ {
 
 /**
- * A Gaussian mixture model class.
+ * A Gaussian Mixture Model (GMM). This class uses maximum likelihood loss
+ * functions to estimate the parameters of the GMM on a given dataset via the EM
+ * algorithm.  The GMM can be trained either with labeled or unlabeled data.
  *
- * This class uses maximum likelihood loss functions to
- * estimate the parameters of a gaussian mixture
- * model on a given data via the EM algorithm.
+ * The GMM, once trained, can be used to generate random points from the
+ * distribution and estimate the probability of points being from the
+ * distribution.  The parameters of the GMM can be obtained through the
+ * accessors and mutators.
  *
- *
  * Example use:
  *
  * @code
- * GMM mog;
- * ArrayList<double> results;
+ * // Set up a mixture of 5 gaussians in a 4-dimensional space.
+ * GMM g(5, 4);
  *
- * mog.Init(number_of_gaussians, dimensionality);
- * mog.ExpectationMaximization(data, &results, optim_flag);
+ * // Train the GMM given the data observations.
+ * g.Estimate(data);
+ *
+ * // Get the probability of 'observation' being observed from this GMM.
+ * double probability = g.Probability(observation);
  * @endcode
  */
 class GMM {
@@ -48,9 +53,7 @@
   /**
    * Create an empty Gaussian Mixture Model, with zero gaussians.
    */
-  GMM() :
-    gaussians(0),
-    dimensionality(0)
+  GMM() : gaussians(0), dimensionality(0)
   {
     // Warn the user.  They probably don't want to do this.  If this constructor
     // is being used (because it is required by some template classes), the user

Modified: mlpack/trunk/src/mlpack/methods/gmm/phi.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/gmm/phi.hpp	2011-12-14 13:15:13 UTC (rev 10777)
+++ mlpack/trunk/src/mlpack/methods/gmm/phi.hpp	2011-12-14 13:15:40 UTC (rev 10778)
@@ -14,35 +14,45 @@
 namespace gmm {
 
 /**
- * Calculates the univariate Gaussian probability density function
+ * Calculates the univariate Gaussian probability density function.
  *
  * Example use:
  * @code
  * double x, mean, var;
  * ....
- * long double f = phi(x, mean, var);
+ * double f = phi(x, mean, var);
  * @endcode
+ *
+ * @param x Observation.
+ * @param mean Mean of univariate Gaussian.
+ * @param var Variance of univariate Gaussian.
+ * @return Probability of x being observed from the given univariate Gaussian.
  */
-inline long double phi(const double x, const double mean, const double var)
+inline double phi(const double x, const double mean, const double var)
 {
   return exp(-1.0 * ((x - mean) * (x - mean) / (2 * var)))
       / sqrt(2 * M_PI * var);
 }
 
 /**
- * Calculates the multivariate Gaussian probability density function
+ * Calculates the multivariate Gaussian probability density function.
  *
  * Example use:
  * @code
- * Vector x, mean;
- * Matrix cov;
+ * extern arma::vec x, mean;
+ * extern arma::mat cov;
  * ....
- * long double f = phi(x, mean, cov);
+ * double f = phi(x, mean, cov);
  * @endcode
+ *
+ * @param x Observation.
+ * @param mean Mean of multivariate Gaussian.
+ * @param cov Covariance of multivariate Gaussian.
+ * @return Probability of x being observed from the given multivariate Gaussian.
  */
-inline long double phi(const arma::vec& x,
-                       const arma::vec& mean,
-                       const arma::mat& cov)
+inline double phi(const arma::vec& x,
+                  const arma::vec& mean,
+                  const arma::mat& cov)
 {
   arma::vec diff = mean - x;
 
@@ -59,18 +69,18 @@
  *
  * Example use:
  * @code
- * Vector x, mean, g_mean, g_cov;
- * ArrayList<Matrix> d_cov; // the dSigma
+ * extern arma::vec x, mean, g_mean, g_cov;
+ * std::vector<arma::mat> d_cov; // the dSigma
  * ....
- * long double f = phi(x, mean, cov, d_cov, &g_mean, &g_cov);
+ * double f = phi(x, mean, cov, d_cov, &g_mean, &g_cov);
  * @endcode
  */
-inline long double phi(const arma::vec& x,
-                       const arma::vec& mean,
-                       const arma::mat& cov,
-                       const std::vector<arma::mat>& d_cov,
-                       arma::vec& g_mean,
-                       arma::vec& g_cov)
+inline double phi(const arma::vec& x,
+                  const arma::vec& mean,
+                  const arma::mat& cov,
+                  const std::vector<arma::mat>& d_cov,
+                  arma::vec& g_mean,
+                  arma::vec& g_cov)
 {
   // We don't call out to another version of the function to avoid inverting the
   // covariance matrix more than once.
@@ -102,6 +112,11 @@
  * Calculates the multivariate Gaussian probability density function for each
  * data point (column) in the given matrix, with respect to the given mean and
  * variance.
+ *
+ * @param x List of observations.
+ * @param mean Mean of multivariate Gaussian.
+ * @param cov Covariance of multivariate Gaussian.
+ * @param probabilities Output probabilities for each input observation.
  */
 inline void phi(const arma::mat& x,
                 const arma::vec& mean,




More information about the mlpack-svn mailing list