MLPACK
1.0.4
|
This class contains methods which can fit a GMM to observations using the EM algorithm. More...
Public Member Functions | |
EMFit (InitialClusteringType clusterer=InitialClusteringType()) | |
Construct the EMFit object, optionally passing an InitialClusteringType object (just in case it needs to store state). | |
void | Estimate (const arma::mat &observations, std::vector< arma::vec > &means, std::vector< arma::mat > &covariances, arma::vec &weights) |
Fit the observations to a Gaussian mixture model (GMM) using the EM algorithm. | |
void | Estimate (const arma::mat &observations, const arma::vec &probabilities, std::vector< arma::vec > &means, std::vector< arma::mat > &covariances, arma::vec &weights) |
Fit the observations to a Gaussian mixture model (GMM) using the EM algorithm, taking into account the probabilities of each point being from this mixture. | |
Private Member Functions | |
void | InitialClustering (const arma::mat &observations, std::vector< arma::vec > &means, std::vector< arma::mat > &covariances, arma::vec &weights) |
Run the clusterer, and then turn the cluster assignments into Gaussians. | |
double | LogLikelihood (const arma::mat &data, const std::vector< arma::vec > &means, const std::vector< arma::mat > &covariances, const arma::vec &weights) const |
Calculate the log-likelihood of a model. | |
Private Attributes | |
InitialClusteringType | clusterer |
This class contains methods which can fit a GMM to observations using the EM algorithm.
It requires an initial clustering mechanism, which is by default the KMeans algorithm. The clustering mechanism must implement the following method:
This method should create 'clusters' clusters, and return the assignment of each point to a cluster.
Definition at line 48 of file em_fit.hpp.
mlpack::gmm::EMFit< InitialClusteringType >::EMFit | ( | InitialClusteringType | clusterer = InitialClusteringType() | ) | [inline] |
Construct the EMFit object, optionally passing an InitialClusteringType object (just in case it needs to store state).
Definition at line 55 of file em_fit.hpp.
void mlpack::gmm::EMFit< InitialClusteringType >::Estimate | ( | const arma::mat & | observations, |
std::vector< arma::vec > & | means, | ||
std::vector< arma::mat > & | covariances, | ||
arma::vec & | weights | ||
) |
Fit the observations to a Gaussian mixture model (GMM) using the EM algorithm.
The size of the vectors (indicating the number of components) must already be set.
observations | List of observations to train on. |
means | Vector to store trained means in. |
covariances | Vector to store trained covariances in. |
weights | Vector to store a priori weights in. |
void mlpack::gmm::EMFit< InitialClusteringType >::Estimate | ( | const arma::mat & | observations, |
const arma::vec & | probabilities, | ||
std::vector< arma::vec > & | means, | ||
std::vector< arma::mat > & | covariances, | ||
arma::vec & | weights | ||
) |
Fit the observations to a Gaussian mixture model (GMM) using the EM algorithm, taking into account the probabilities of each point being from this mixture.
The size of the vectors (indicating the number of components) must already be set.
observations | List of observations to train on. |
probabilities | Probability of each point being from this model. |
means | Vector to store trained means in. |
covariances | Vector to store trained covariances in. |
weights | Vector to store a priori weights in. |
void mlpack::gmm::EMFit< InitialClusteringType >::InitialClustering | ( | const arma::mat & | observations, |
std::vector< arma::vec > & | means, | ||
std::vector< arma::mat > & | covariances, | ||
arma::vec & | weights | ||
) | [private] |
Run the clusterer, and then turn the cluster assignments into Gaussians.
This is a helper function for both overloads of Estimate(). The vectors must be already set to the number of clusters.
observations | List of observations. |
means | Vector to store means in. |
covariances | Vector to store covariances in. |
weights | Vector to store a priori weights in. |
double mlpack::gmm::EMFit< InitialClusteringType >::LogLikelihood | ( | const arma::mat & | data, |
const std::vector< arma::vec > & | means, | ||
const std::vector< arma::mat > & | covariances, | ||
const arma::vec & | weights | ||
) | const [private] |
Calculate the log-likelihood of a model.
Yes, this is reimplemented in the GMM code. Intuition suggests that the log-likelihood is not the best way to determine if the EM algorithm has converged.
data | Data matrix. |
means | Vector of means. |
covariances | Vector of covariance matrices. |
weights | Vector of a priori weights. |
InitialClusteringType mlpack::gmm::EMFit< InitialClusteringType >::clusterer [private] |
Definition at line 122 of file em_fit.hpp.