14 #ifndef MLPACK_METHODS_GMM_DIAGONAL_GMM_HPP 15 #define MLPACK_METHODS_GMM_DIAGONAL_GMM_HPP 80 size_t dimensionality;
83 std::vector<distribution::DiagonalGaussianDistribution> dists;
99 Log::Debug <<
"DiagonalGMM::DiagonalGMM(): no parameters given;" 100 "Estimate() may fail " <<
"unless parameters are set." << std::endl;
110 DiagonalGMM(
const size_t gaussians,
const size_t dimensionality);
118 DiagonalGMM(
const std::vector<distribution::DiagonalGaussianDistribution>&
119 dists,
const arma::vec& weights) :
120 gaussians(dists.size()),
121 dimensionality((!dists.empty()) ? dists[0].Mean().n_elem : 0),
157 const arma::vec&
Weights()
const {
return weights; }
167 double Probability(
const arma::vec& observation)
const;
175 void Probability(
const arma::mat& observation, arma::vec& probs)
const;
191 void LogProbability(
const arma::mat& observation, arma::vec& logProbs)
const;
201 const size_t component)
const;
211 const size_t component)
const;
242 template<
typename FittingType = EMFit<kmeans::KMeans<>, DiagonalConstra
int,
243 distribution::DiagonalGaussianDistribution>>
244 double Train(
const arma::mat& observations,
245 const size_t trials = 1,
246 const bool useExistingModel =
false,
247 FittingType fitter = FittingType());
274 template<
typename FittingType = EMFit<kmeans::KMeans<>, DiagonalConstra
int,
275 distribution::DiagonalGaussianDistribution>>
276 double Train(
const arma::mat& observations,
277 const arma::vec& probabilities,
278 const size_t trials = 1,
279 const bool useExistingModel =
false,
280 FittingType fitter = FittingType());
299 void Classify(
const arma::mat& observations,
300 arma::Row<size_t>& labels)
const;
305 template<
typename Archive>
306 void serialize(Archive& ar,
const uint32_t );
318 double LogLikelihood(
319 const arma::mat& observations,
320 const std::vector<distribution::DiagonalGaussianDistribution>& dists,
321 const arma::vec& weights)
const;
328 #include "diagonal_gmm_impl.hpp" 330 #endif // MLPACK_METHODS_GMM_DIAGONAL_GMM_HPP
Linear algebra utility functions, generally performed on matrices or vectors.
arma::vec & Weights()
Return a reference to the a priori weights of each Gaussian.
double Probability(const arma::vec &observation) const
Return the probability that the given observation came from this distribution.
const arma::vec & Weights() const
Return a const reference to the a priori weights of each Gaussian.
static MLPACK_EXPORT util::NullOutStream Debug
MLPACK_EXPORT is required for global variables, so that they are properly exported by the Windows com...
A Diagonal Gaussian Mixture Model.
The core includes that mlpack expects; standard C++ includes and Armadillo.
const distribution::DiagonalGaussianDistribution & Component(size_t i) const
Return a const reference to a component distribution.
arma::vec Random() const
Return a randomly generated observation according to the probability distribution defined by this obj...
DiagonalGMM & operator=(const DiagonalGMM &other)
Copy operator for DiagonalGMMs.
DiagonalGMM(const std::vector< distribution::DiagonalGaussianDistribution > &dists, const arma::vec &weights)
Create a DiagonalGMM with the given dists and weights.
distribution::DiagonalGaussianDistribution & Component(size_t i)
Return a reference to a component distribution.
void Classify(const arma::mat &observations, arma::Row< size_t > &labels) const
Classify the given observations as being from an individual component in this DiagonalGMM.
DiagonalGMM()
Create an empty Diagonal Gaussian Mixture Model, with zero gaussians.
double LogProbability(const arma::vec &observation) const
Return the log probability that the given observation came from this distribution.
size_t Dimensionality() const
Return the dimensionality of the model.
void serialize(Archive &ar, const uint32_t)
Serialize the DiagonalGMM.
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 Gaussians() const
Return the number of Gaussians in the model.
A single multivariate Gaussian distribution with diagonal covariance.