16 #ifndef __MLPACK_METHODS_GMM_EM_FIT_HPP 17 #define __MLPACK_METHODS_GMM_EM_FIT_HPP 42 template<
typename InitialClusteringType = kmeans::KMeans<>,
43 typename CovarianceConstra
intPolicy = PositiveDefiniteConstra
int>
66 InitialClusteringType
clusterer = InitialClusteringType(),
67 CovarianceConstraintPolicy
constraint = CovarianceConstraintPolicy());
84 void Estimate(
const arma::mat& observations,
85 std::vector<distribution::GaussianDistribution>& dists,
87 const bool useInitialModel =
false);
106 void Estimate(
const arma::mat& observations,
107 const arma::vec& probabilities,
108 std::vector<distribution::GaussianDistribution>& dists,
110 const bool useInitialModel =
false);
133 template<
typename Archive>
134 void Serialize(Archive& ar,
const unsigned int version);
148 std::vector<distribution::GaussianDistribution>& dists,
162 const std::vector<distribution::GaussianDistribution>&
164 const arma::vec& weights)
const;
180 #include "em_fit_impl.hpp" This class contains methods which can fit a GMM to observations using the EM algorithm.
void Estimate(const arma::mat &observations, std::vector< distribution::GaussianDistribution > &dists, arma::vec &weights, const bool useInitialModel=false)
Fit the observations to a Gaussian mixture model (GMM) using the EM algorithm.
double & Tolerance()
Modify the tolerance for the convergence of the EM algorithm.
Linear algebra utility functions, generally performed on matrices or vectors.
void InitialClustering(const arma::mat &observations, std::vector< distribution::GaussianDistribution > &dists, arma::vec &weights)
Run the clusterer, and then turn the cluster assignments into Gaussians.
double LogLikelihood(const arma::mat &data, const std::vector< distribution::GaussianDistribution > &dists, const arma::vec &weights) const
Calculate the log-likelihood of a model.
size_t maxIterations
Maximum iterations of EM algorithm.
CovarianceConstraintPolicy constraint
Object which applies constraints to the covariance matrix.
size_t & MaxIterations()
Modify the maximum number of iterations of the EM algorithm.
size_t MaxIterations() const
Get the maximum number of iterations of the EM algorithm.
InitialClusteringType & Clusterer()
Modify the clusterer.
EMFit(const size_t maxIterations=300, const double tolerance=1e-10, InitialClusteringType clusterer=InitialClusteringType(), CovarianceConstraintPolicy constraint=CovarianceConstraintPolicy())
Construct the EMFit object, optionally passing an InitialClusteringType object (just in case it needs...
CovarianceConstraintPolicy & Constraint()
Modify the covariance constraint policy class.
Include all of the base components required to write MLPACK methods, and the main MLPACK Doxygen docu...
InitialClusteringType clusterer
Object which will perform the clustering.
double tolerance
Tolerance for convergence of EM.
const CovarianceConstraintPolicy & Constraint() const
Get the covariance constraint policy class.
void Serialize(Archive &ar, const unsigned int version)
Serialize the fitter.
const InitialClusteringType & Clusterer() const
Get the clusterer.
double Tolerance() const
Get the tolerance for the convergence of the EM algorithm.