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; }
165 double Probability(
const arma::vec& observation)
const;
173 void Probability(
const arma::mat& observation, arma::vec& probs)
const;
189 void LogProbability(
const arma::mat& observation, arma::vec& logProbs)
const;
199 const size_t component)
const;
209 const size_t component)
const;
241 template<
typename FittingType = EMFit<>>
242 double Train(
const arma::mat& observations,
243 const size_t trials = 1,
244 const bool useExistingModel =
false,
245 FittingType fitter = FittingType());
272 template<
typename FittingType = EMFit<>>
273 double Train(
const arma::mat& observations,
274 const arma::vec& probabilities,
275 const size_t trials = 1,
276 const bool useExistingModel =
false,
277 FittingType fitter = FittingType());
295 void Classify(
const arma::mat& observations,
296 arma::Row<size_t>& labels)
const;
301 template<
typename Archive>
302 void serialize(Archive& ar,
const uint32_t );
314 double LogLikelihood(
315 const arma::mat& dataPoints,
316 const std::vector<distribution::GaussianDistribution>& distsL,
317 const arma::vec& weights)
const;
324 #include "gmm_impl.hpp" GMM(const std::vector< distribution::GaussianDistribution > &dists, const arma::vec &weights)
Create a GMM with the given dists and weights.
A single multivariate Gaussian distribution.
void serialize(Archive &ar, const uint32_t)
Serialize the GMM.
arma::vec & Weights()
Return a reference to the a priori weights of each Gaussian.
Linear algebra utility functions, generally performed on matrices or vectors.
static MLPACK_EXPORT util::NullOutStream Debug
MLPACK_EXPORT is required for global variables, so that they are properly exported by the Windows com...
GMM()
Create an empty Gaussian Mixture Model, with zero gaussians.
The core includes that mlpack expects; standard C++ includes and Armadillo.
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.
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.
double Probability(const arma::vec &observation) const
Return the probability that the given observation came from this distribution.
const distribution::GaussianDistribution & Component(size_t i) const
Return a const reference to a component distribution.
A Gaussian Mixture Model (GMM).
distribution::GaussianDistribution & Component(size_t i)
Return a reference to a component distribution.
arma::vec Random() const
Return a randomly generated observation according to the probability distribution defined by this obj...
double LogProbability(const arma::vec &observation) const
Return the log probability that the given observation came from this distribution.
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...
size_t Dimensionality() const
Return the dimensionality of the model.
size_t Gaussians() const
Return the number of gaussians in the model.