[mlpack-svn] r10390 - in mlpack/trunk/src/mlpack/methods: . gmm
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Thu Nov 24 02:25:55 EST 2011
Author: rcurtin
Date: 2011-11-24 02:25:55 -0500 (Thu, 24 Nov 2011)
New Revision: 10390
Removed:
mlpack/trunk/src/mlpack/methods/nnsvm/
mlpack/trunk/src/mlpack/methods/svm/
Modified:
mlpack/trunk/src/mlpack/methods/CMakeLists.txt
mlpack/trunk/src/mlpack/methods/gmm/gmm.cpp
mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp
Log:
These methods are unmaintainable and will have to be re-implemented.
Modified: mlpack/trunk/src/mlpack/methods/CMakeLists.txt
===================================================================
--- mlpack/trunk/src/mlpack/methods/CMakeLists.txt 2011-11-24 07:14:00 UTC (rev 10389)
+++ mlpack/trunk/src/mlpack/methods/CMakeLists.txt 2011-11-24 07:25:55 UTC (rev 10390)
@@ -11,10 +11,8 @@
#mvu # (currently known to not work)
naive_bayes
nca
- pca
neighbor_search
- nnsvm
- svm
+ pca
)
foreach(dir ${DIRS})
Modified: mlpack/trunk/src/mlpack/methods/gmm/gmm.cpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/gmm/gmm.cpp 2011-11-24 07:14:00 UTC (rev 10389)
+++ mlpack/trunk/src/mlpack/methods/gmm/gmm.cpp 2011-11-24 07:25:55 UTC (rev 10390)
@@ -13,6 +13,26 @@
using namespace mlpack;
using namespace gmm;
+double GMM::Probability(const arma::vec& observation) const
+{
+ // Sum the probability for each Gaussian in our mixture (and we have to
+ // multiply by the prior for each Gaussian too).
+ double sum = 0;
+ for (size_t i = 0; i < gaussians; i++)
+ sum += weights[i] * phi(observation, means[i], covariances[i]);
+
+ return sum;
+}
+
+/**
+ * Return a randomly generated observation according to the probability
+ * distribution defined by this object.
+ */
+arma::vec GMM::Random() const
+{
+ return "0 0";
+}
+
void GMM::ExpectationMaximization(const arma::mat& data)
{
// Create temporary models and set to the right size.
Modified: mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp
===================================================================
--- mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp 2011-11-24 07:14:00 UTC (rev 10389)
+++ mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp 2011-11-24 07:25:55 UTC (rev 10390)
@@ -84,49 +84,28 @@
//! Return a reference to the a priori weights of each Gaussian.
arma::vec& Weights() { return weights; }
+
/**
- * This function outputs the parameters of the model
- * to an arraylist of doubles
+ * Return the probability that the given observation came from this
+ * distribution.
*
- * @code
- * ArrayList<double> results;
- * mog.OutputResults(&results);
- * @endcode
+ * @param observation Observation to evaluate the probability of.
*/
- void OutputResults(std::vector<double>& results)
- {
- // Initialize the size of the output array
- results.resize(gaussians * (1 + dimension * (1 + dimension)));
+ double Probability(const arma::vec& observation) const;
- // Copy values to the array from the private variables of the class
- for (size_t i = 0; i < gaussians; i++)
- {
- results[i] = weights[i];
- for (size_t j = 0; j < dimension; j++)
- {
- results[gaussians + (i * dimension) + j] = (means[i])[j];
- for (size_t k = 0; k < dimension; k++)
- {
- results[gaussians * (1 + dimension) +
- (i * dimension * dimension) + (j * dimension) + k] =
- (covariances[i])(j, k);
- }
- }
- }
- }
-
/**
- * This function calculates the parameters of the model
- * using the Maximum Likelihood function via the
- * Expectation Maximization (EM) Algorithm.
+ * Return a randomly generated observation according to the probability
+ * distribution defined by this object.
*
- * @code
- * MoG mog;
- * Matrix data = "the data on which you want to fit the model";
- * ArrayList<double> results;
- * mog.ExpectationMaximization(data, &results);
- * @endcode
+ * @return Random observation from this GMM.
*/
+ arma::vec Random() const;
+
+ /**
+ * This function estimates the parameters of the Gaussian Mixture Model using
+ * the Maximum Likelihood estimator, via the EM (Expectation Maximization)
+ * algorithm.
+ */
void ExpectationMaximization(const arma::mat& data_points);
/**
More information about the mlpack-svn
mailing list