15 #ifndef __MLPACK_METHODS_MOG_MOG_EM_HPP
16 #define __MLPACK_METHODS_MOG_MOG_EM_HPP
80 template<
typename FittingType = EMFit<> >
108 Log::Debug <<
"GMM::GMM(): no parameters given; Estimate() may fail "
109 <<
"unless parameters are set." << std::endl;
119 GMM(
const size_t gaussians,
const size_t dimensionality);
131 GMM(
const size_t gaussians,
132 const size_t dimensionality,
142 GMM(
const std::vector<arma::vec>& means,
143 const std::vector<arma::mat>& covariances,
144 const arma::vec& weights) :
145 gaussians(means.size()),
146 dimensionality((!means.empty()) ? means[0].n_elem : 0),
148 covariances(covariances),
162 GMM(
const std::vector<arma::vec>& means,
163 const std::vector<arma::mat>& covariances,
164 const arma::vec& weights,
166 gaussians(means.size()),
167 dimensionality((!means.empty()) ? means[0].n_elem : 0),
169 covariances(covariances),
176 template<
typename OtherFittingType>
188 template<
typename OtherFittingType>
203 void Load(
const std::string& filename);
210 void Save(
const std::string& filename)
const;
225 const std::vector<arma::vec>&
Means()
const {
return means; }
250 double Probability(
const arma::vec& observation)
const;
260 const size_t component)
const;
292 double Estimate(
const arma::mat& observations,
293 const size_t trials = 1,
294 const bool useExistingModel =
false);
320 double Estimate(
const arma::mat& observations,
321 const arma::vec& probabilities,
322 const size_t trials = 1,
323 const bool useExistingModel =
false);
341 void Classify(
const arma::mat& observations,
342 arma::Col<size_t>& labels)
const;
360 const std::vector<arma::vec>& means,
361 const std::vector<arma::mat>& covars,
362 const arma::vec& weights)
const;
375 #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.
Linear algebra utility functions, generally performed on matrices or vectors.
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.