23 #ifndef __MLPACK_METHODS_MOG_MOG_EM_HPP
24 #define __MLPACK_METHODS_MOG_MOG_EM_HPP
88 template<
typename FittingType = EMFit<> >
116 Log::Debug <<
"GMM::GMM(): no parameters given; Estimate() may fail "
117 <<
"unless parameters are set." << std::endl;
156 covariances(covariances),
177 covariances(covariances),
184 template<
typename OtherFittingType>
196 template<
typename OtherFittingType>
211 void Load(
const std::string& filename);
218 void Save(
const std::string& filename)
const;
233 const std::vector<arma::vec>&
Means()
const {
return means; }
258 double Probability(
const arma::vec& observation)
const;
268 const size_t component)
const;
300 double Estimate(
const arma::mat& observations,
301 const size_t trials = 1,
302 const bool useExistingModel =
false);
328 double Estimate(
const arma::mat& observations,
329 const arma::vec& probabilities,
330 const size_t trials = 1,
331 const bool useExistingModel =
false);
349 void Classify(
const arma::mat& observations,
350 arma::Col<size_t>& labels)
const;
368 const std::vector<arma::vec>&
means,
369 const std::vector<arma::mat>& covars,
370 const arma::vec&
weights)
const;
383 #include "gmm_impl.hpp"
FittingType & fitter
Reference to the fitting object we should use.
const arma::vec & Weights() const
Return a const reference to the a priori weights of each Gaussian.
std::vector< arma::vec > & Means()
Return a reference to the vector of means (mu).
GMM()
Create an empty Gaussian Mixture Model, with zero gaussians.
FittingType localFitter
Locally-stored fitting object; in case the user did not pass one.
std::vector< arma::mat > & Covariances()
Return a reference to the vector of covariance matrices (sigma).
size_t & Gaussians()
Modify the number of gaussians in the model.
double Estimate(const arma::mat &observations, const size_t trials=1, const bool useExistingModel=false)
Estimate the probability distribution directly from the given observations, using the given algorithm...
double LogLikelihood(const arma::mat &dataPoints, const std::vector< arma::vec > &means, const std::vector< arma::mat > &covars, const arma::vec &weights) const
This function computes the loglikelihood of the given model.
std::vector< arma::mat > covariances
Vector of covariances; one for each Gaussian.
arma::vec weights
Vector of a priori weights for each Gaussian.
FittingType & Fitter()
Return a reference to the fitting type.
void Classify(const arma::mat &observations, arma::Col< size_t > &labels) const
Classify the given observations as being from an individual component in this GMM.
double Probability(const arma::vec &observation) const
Return the probability that the given observation came from this distribution.
GMM(const std::vector< arma::vec > &means, const std::vector< arma::mat > &covariances, const arma::vec &weights, FittingType &fitter)
Create a GMM with the given means, covariances, and weights, and use the given initialized FittingTyp...
arma::vec & Weights()
Return a reference to the a priori weights of each Gaussian.
const std::vector< arma::mat > & Covariances() const
Return a const reference to the vector of covariance matrices (sigma).
size_t & Dimensionality()
Modify the dimensionality of the model.
GMM(const std::vector< arma::vec > &means, const std::vector< arma::mat > &covariances, const arma::vec &weights)
Create a GMM with the given means, covariances, and weights.
const std::vector< arma::vec > & Means() const
Return a const reference to the vector of means (mu).
A Gaussian Mixture Model (GMM).
std::vector< arma::vec > means
Vector of means; one for each Gaussian.
static util::NullOutStream Debug
Dumps debug output into the bit nether regions.
void Save(const std::string &filename) const
Save a GMM to an XML file.
const FittingType & Fitter() const
Return a const reference to the fitting type.
size_t dimensionality
The dimensionality of the model.
GMM & operator=(const GMM< OtherFittingType > &other)
Copy operator for GMMs which use different fitting types.
std::string ToString() const
Returns a string representation of this object.
void Load(const std::string &filename)
Load a GMM from an XML file.
arma::vec Random() const
Return a randomly generated observation according to the probability distribution defined by this obj...
size_t Dimensionality() const
Return the dimensionality of the model.
size_t Gaussians() const
Return the number of gaussians in the model.
size_t gaussians
The number of Gaussians in the model.