|
Gaussian Mixture Model
|
Public Member Functions | |
| GaussianMixtureModel (Eigen::MatrixXd samples, int num_components) | |
| Use this method to initialize a GMM fitting given data samples with the desired number of components. Training is done with Expectation-Maximization algorithm. More... | |
| GaussianMixtureModel (std::vector< Eigen::VectorXd > means, std::vector< Eigen::MatrixXd > covariances, std::vector< double > weights) | |
| Use this method to initialize a GMM starting from mean points and covariance matrices already known. Faster than fitting a GMM from a dataset. The number of component is equal to the number of elements in the input vectors. More... | |
| GaussianMixtureModel (int num_components) | |
| Use this method to initialize a GMM from random mean points and covariance matrices. DEPRECATED! The fitting procedure is very slow. It's better to initialize an empty GMM and then set the parameters with the setter methods. More... | |
| GaussianMixtureModel () | |
| Use this method to initialize an empty GMM. Parameters must be set with the setter methods. | |
| ~GaussianMixtureModel () | |
| Destructor. | |
| void | fitgmm (Eigen::MatrixXd samples, int num_components, int max_iterations, double tolerance, bool verbose) |
| Expectation-Maximization algorithm. Fits a GMM to a dataset recursively iterating between E-step and M-step. Iterations stop when the log likelihood of the data does not change more than a specified tolerance or when the maximum number of iterations is reached. The GMM must be already initialized. More... | |
| void | fitgmm2 (Eigen::MatrixXd samples, int num_components, int max_iterations, double tolerance, bool verbose) |
| Expectation-Maximization algorithm. Fits a GMM to a dataset recursively iterating between E-step and M-step. Iterations stop when the log likelihood of the data does not change more than a specified tolerance or when the maximum number of iterations is reached. The GMM must be already initialized. More... | |
| void | fitgmm (std::vector< Eigen::VectorXd > samples, int num_components, int max_iterations, double tolerance, bool verbose) |
| Expectation-Maximization algorithm. Fits a GMM to a dataset recursively iterating between E-step and M-step. Iterations stop when the log likelihood of the data does not change more than a specified tolerance or when the maximum number of iterations is reached. The GMM must be already initialized. Result is the same as above, but convergence should be faster. More... | |
| std::vector< Eigen::VectorXd > | getMeans () |
| Mean getter. More... | |
| std::vector< Eigen::MatrixXd > | getCovariances () |
| Covariances getter. More... | |
| std::vector< double > | getWeights () |
| Weights getter. More... | |
| double | getLogLikelihood () |
| Log-likelihood getter. More... | |
| void | setMeans (std::vector< Eigen::VectorXd > means) |
| Mean points setter method. More... | |
| void | setCovariances (std::vector< Eigen::MatrixXd > covariances) |
| Covariance matrices setter method. More... | |
| void | setWeights (std::vector< double > weights) |
| Weights setter method. More... | |
| bool | check () |
| Check dimensions consistency of the GMM parameters. More... | |
| double | gauss_pdf_2d (Eigen::VectorXd q, Eigen::VectorXd mean, Eigen::MatrixXd cov) |
| Use this method to calculate the probability of a given 2D point from a Bivariate Gaussian Distribution (single component). More... | |
| GaussianMixtureModel::GaussianMixtureModel | ( | Eigen::MatrixXd | samples, |
| int | num_components | ||
| ) |
Use this method to initialize a GMM fitting given data samples with the desired number of components. Training is done with Expectation-Maximization algorithm.
| [in] | samples | training set |
| [in] | num_components | desired number of clusters |
| GaussianMixtureModel::GaussianMixtureModel | ( | std::vector< Eigen::VectorXd > | means, |
| std::vector< Eigen::MatrixXd > | covariances, | ||
| std::vector< double > | weights | ||
| ) |
Use this method to initialize a GMM starting from mean points and covariance matrices already known. Faster than fitting a GMM from a dataset. The number of component is equal to the number of elements in the input vectors.
| [in] | means | vector of mean points, one for each cluster |
| [in] | covariances | vector of covariance matrices, one for each cluster |
| [in] | weights | mixture proportion of each cluster |
| return | error if size of input vectors is not consistent |
| GaussianMixtureModel::GaussianMixtureModel | ( | int | num_components | ) |
Use this method to initialize a GMM from random mean points and covariance matrices. DEPRECATED! The fitting procedure is very slow. It's better to initialize an empty GMM and then set the parameters with the setter methods.
| [in] | num_components | number of clusters |
| bool GaussianMixtureModel::check | ( | ) |
Check dimensions consistency of the GMM parameters.
| void GaussianMixtureModel::fitgmm | ( | Eigen::MatrixXd | samples, |
| int | num_components, | ||
| int | max_iterations = 1000, |
||
| double | tolerance = 1e-3, |
||
| bool | verbose = false |
||
| ) |
Expectation-Maximization algorithm. Fits a GMM to a dataset recursively iterating between E-step and M-step. Iterations stop when the log likelihood of the data does not change more than a specified tolerance or when the maximum number of iterations is reached. The GMM must be already initialized.
| [in] | samples | matrix of data samples. Each column is a sample. |
| [in] | num_components | number of clusters |
| [in] | max_iterations | maximum number of iterations (default: 1000) |
| [in] | tolerance | convergence threshold (default: 1e-3) |
| [in] | verbose | print number of iterations, final log_likelihood and time required for computation (default: false) |
| void GaussianMixtureModel::fitgmm | ( | std::vector< Eigen::VectorXd > | samples, |
| int | num_components, | ||
| int | max_iterations = 1000, |
||
| double | tolerance = 1e-3, |
||
| bool | verbose = false |
||
| ) |
Expectation-Maximization algorithm. Fits a GMM to a dataset recursively iterating between E-step and M-step. Iterations stop when the log likelihood of the data does not change more than a specified tolerance or when the maximum number of iterations is reached. The GMM must be already initialized. Result is the same as above, but convergence should be faster.
| [in] | samples | vector of samples. Each element of the std::vector contains coordinates of a sample. |
| [in] | num_components | number of clusters |
| [in] | max_iterations | maximum number of iterations (default: 1000) |
| [in] | tolerance | convergence threshold (default: 1e-3) |
| [in] | verbose | print number of iterations, final log_likelihood and time required for computation (default: false) |
| void GaussianMixtureModel::fitgmm2 | ( | Eigen::MatrixXd | samples, |
| int | num_components, | ||
| int | max_iterations = 1000, |
||
| double | tolerance = 1e-3, |
||
| bool | verbose = false |
||
| ) |
Expectation-Maximization algorithm. Fits a GMM to a dataset recursively iterating between E-step and M-step. Iterations stop when the log likelihood of the data does not change more than a specified tolerance or when the maximum number of iterations is reached. The GMM must be already initialized.
| [in] | samples | matrix of data samples. Each column is a sample. |
| [in] | num_components | number of clusters |
| [in] | max_iterations | maximum number of iterations (default: 1000) |
| [in] | tolerance | convergence threshold (default: 1e-3) |
| [in] | verbose | print number of iterations, final log_likelihood and time required for computation (default: false) |
| double GaussianMixtureModel::gauss_pdf_2d | ( | Eigen::VectorXd | q, |
| Eigen::VectorXd | mean, | ||
| Eigen::MatrixXd | cov | ||
| ) |
Use this method to calculate the probability of a given 2D point from a Bivariate Gaussian Distribution (single component).
| [in] | q | considered point coordinates |
| [in] | mean | mean point of the Bivariate Gaussian Distribution |
| [in] | cov | covariance matrix of the Bivariate Gaussian Distribution |
| std::vector< Eigen::MatrixXd > GaussianMixtureModel::getCovariances | ( | ) |
Covariances getter.
| double GaussianMixtureModel::getLogLikelihood | ( | ) |
Log-likelihood getter.
| std::vector< Eigen::VectorXd > GaussianMixtureModel::getMeans | ( | ) |
Mean getter.
| std::vector< double > GaussianMixtureModel::getWeights | ( | ) |
Weights getter.
| void GaussianMixtureModel::setCovariances | ( | std::vector< Eigen::MatrixXd > | covariances | ) |
Covariance matrices setter method.
| [in] | covariances | vector of covariance matrices of each Gaussian component |
| void GaussianMixtureModel::setMeans | ( | std::vector< Eigen::VectorXd > | means | ) |
Mean points setter method.
| [in] | means | vector of mean points of each Gaussian component |
| void GaussianMixtureModel::setWeights | ( | std::vector< double > | weights | ) |
Weights setter method.
| [in] | weights | vector of weights of each Gaussian component |
1.8.17