Go to the documentation of this file.
13 #ifndef MLPACK_METHODS_MOG_MOG_EM_HPP
14 #define MLPACK_METHODS_MOG_MOG_EM_HPP
84 size_t dimensionality;
87 std::vector<distribution::GaussianDistribution> dists;
103 Log::Debug <<
"GMM::GMM(): no parameters given; Estimate() may fail "
104 <<
"unless parameters are set." << std::endl;
114 GMM(
const size_t gaussians,
const size_t dimensionality);
122 GMM(
const std::vector<distribution::GaussianDistribution> & dists,
123 const arma::vec& weights) :
124 gaussians(dists.size()),
125 dimensionality((!dists.empty()) ? dists[0].Mean().n_elem : 0),
155 const arma::vec&
Weights()
const {
return weights; }
183 const size_t component)
const;
193 const size_t component)
const;
225 template<
typename FittingType = EMFit<>>
226 double Train(
const arma::mat& observations,
227 const size_t trials = 1,
228 const bool useExistingModel =
false,
229 FittingType fitter = FittingType());
256 template<
typename FittingType = EMFit<>>
257 double Train(
const arma::mat& observations,
258 const arma::vec& probabilities,
259 const size_t trials = 1,
260 const bool useExistingModel =
false,
261 FittingType fitter = FittingType());
280 arma::Row<size_t>& labels)
const;
285 template<
typename Archive>
298 double LogLikelihood(
299 const arma::mat& dataPoints,
300 const std::vector<distribution::GaussianDistribution>& distsL,
301 const arma::vec& weights)
const;
308 #include "gmm_impl.hpp"
double Train(const arma::mat &observations, const arma::vec &probabilities, const size_t trials=1, const bool useExistingModel=false, FittingType fitter=FittingType())
Estimate the probability distribution directly from the given observations, taking into account the p...
double Probability(const arma::vec &observation) const
Return the probability that the given observation came from this distribution.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static MLPACK_EXPORT util::NullOutStream Debug
MLPACK_EXPORT is required for global variables, so that they are properly exported by the Windows com...
A Gaussian Mixture Model (GMM).
void serialize(Archive &ar, const unsigned int)
Serialize the GMM.
GMM(const size_t gaussians, const size_t dimensionality)
Create a GMM with the given number of Gaussians, each of which have the specified dimensionality.
arma::vec & Weights()
Return a reference to the a priori weights of each Gaussian.
double LogProbability(const arma::vec &observation) const
Return the log probability that the given observation came from this distribution.
GMM()
Create an empty Gaussian Mixture Model, with zero gaussians.
Linear algebra utility functions, generally performed on matrices or vectors.
void Classify(const arma::mat &observations, arma::Row< size_t > &labels) const
Classify the given observations as being from an individual component in this GMM.
const arma::vec & Weights() const
Return a const reference to the a priori weights of each Gaussian.
GMM & operator=(const GMM &other)
Copy operator for GMMs.
double LogProbability(const arma::vec &observation, const size_t component) const
Return the log probability that the given observation came from the given Gaussian component in this ...
size_t Gaussians() const
Return the number of gaussians in the model.
const distribution::GaussianDistribution & Component(size_t i) const
Return a const reference to a component distribution.
A single multivariate Gaussian distribution.
size_t Dimensionality() const
Return the dimensionality of the model.
arma::vec Random() const
Return a randomly generated observation according to the probability distribution defined by this obj...
double Probability(const arma::vec &observation, const size_t component) const
Return the probability that the given observation came from the given Gaussian component in this dist...
GMM(const GMM &other)
Copy constructor for GMMs.
distribution::GaussianDistribution & Component(size_t i)
Return a reference to a component distribution.
GMM(const std::vector< distribution::GaussianDistribution > &dists, const arma::vec &weights)
Create a GMM with the given dists and weights.
double Train(const arma::mat &observations, const size_t trials=1, const bool useExistingModel=false, FittingType fitter=FittingType())
Estimate the probability distribution directly from the given observations, using the given algorithm...