[mlpack-svn] r10324 - mlpack/trunk/src/mlpack/methods/gmm
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Fri Nov 18 15:42:58 EST 2011
Author: rcurtin
Date: 2011-11-18 15:42:58 -0500 (Fri, 18 Nov 2011)
New Revision: 10324
Modified:
mlpack/trunk/src/mlpack/methods/gmm/gmm_main.cpp
Log:
Flesh out main executable for GMMs.
Modified: mlpack/trunk/src/mlpack/methods/gmm/gmm_main.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/gmm/gmm_main.cpp 2011-11-18 20:42:47 UTC (rev 10323)
+++ mlpack/trunk/src/mlpack/methods/gmm/gmm_main.cpp 2011-11-18 20:42:58 UTC (rev 10324)
@@ -1,35 +1,18 @@
/**
* @author Parikshit Ram (pram at cc.gatech.edu)
- * @file mog_em_main.cpp
+ * @file gmm_main.cpp
*
- * This program test drives the parametric estimation
- * of a Gaussian Mixture model using maximum likelihood.
- *
- * PARAMETERS TO BE INPUT:
- *
- * --data
- * This is the file that contains the data on which
- * the model is to be fit
- *
- * --mog_em/K
- * This is the number of gaussians we want to fit
- * on the data, defaults to '1'
- *
- * --output
- * This file will contain the parameters estimated,
- * defaults to 'ouotput.csv'
- *
+ * This program trains a mixture of Gaussians on a given data matrix.
*/
-#include "mog_em.hpp"
+#include "gmm.hpp"
-PROGRAM_INFO("Mixture of Gaussians",
+PROGRAM_INFO("GMM",
"This program takes a parametric estimate of a Gaussian mixture model (GMM)"
- " using maximum likelihood.", "mog");
+ " using the EM algorithm to find the maximum likelihood estimate.", "");
PARAM_STRING_REQ("data", "A file containing the data on which the model has to "
- "be fit.", "mog");
-PARAM_STRING("output", "The file into which the output is to be written into.",
- "mog", "output.csv");
+ "be fit.", "gmm");
+PARAM_INT("gaussians", "g", "", 1);
using namespace mlpack;
using namespace mlpack::gmm;
@@ -39,29 +22,16 @@
////// READING PARAMETERS AND LOADING DATA //////
arma::mat data_points;
- data::Load(CLI::GetParam<std::string>("mog/data").c_str(), data_points, true);
+ data::Load(CLI::GetParam<std::string>("gmm/data").c_str(), data_points, true);
////// MIXTURE OF GAUSSIANS USING EM //////
- MoGEM mog;
+ GMM gmm(CLI::GetParam<int>("gaussians"), data_points.n_rows);
- CLI::GetParam<int>("mog/k") = 1;
- CLI::GetParam<int>("mog/d") = data_points.n_rows;
-
- ////// Timing the initialization of the mixture model //////
- Timers::StartTimer("mog/model_init");
- mog.Init(1, data_points.n_rows);
- Timers::StopTimer("mog/model_init");
-
////// Computing the parameters of the model using the EM algorithm //////
- std::vector<double> results;
+ Timers::StartTimer("gmm/em");
+ gmm.ExpectationMaximization(data_points);
+ Timers::StopTimer("gmm/em");
- Timers::StartTimer("mog/EM");
- mog.ExpectationMaximization(data_points);
- Timers::StopTimer("mog/EM");
-
- mog.Display();
- mog.OutputResults(results);
-
////// OUTPUT RESULTS //////
// We need a better solution for this. So, currently, we do nothing.
// XML is probably the right tool for the job.
More information about the mlpack-svn
mailing list