mlpack_gmm_train(1) | User Commands | mlpack_gmm_train(1) |
mlpack_gmm_train - gaussian mixture model (gmm) training
mlpack_gmm_train -g int -i string [-d bool] [-m unknown] [-k int] [-n int] [-P bool] [-N double] [-p double] [-r bool] [-S int] [-s int] [-T double] [-t int] [-V bool] [-M unknown] [-h -v]
This program takes a parametric estimate of a Gaussian mixture model (GMM) using the EM algorithm to find the maximum likelihood estimate. The model may be saved and reused by other mlpack GMM tools.
The input data to train on must be specified with the '--input_file (-i)' parameter, and the number of Gaussians in the model must be specified with the ’--gaussians (-g)' parameter. Optionally, many trials with different random initializations may be run, and the result with highest log-likelihood on the training data will be taken. The number of trials to run is specified with the '--trials (-t)' parameter. By default, only one trial is run.
The tolerance for convergence and maximum number of iterations of the EM algorithm are specified with the '--tolerance (-T)' and '--max_iterations (-n)' parameters, respectively. The GMM may be initialized for training with another model, specified with the '--input_model_file (-m)' parameter. Otherwise, the model is initialized by running k-means on the data. The k-means clustering initialization can be controlled with the ’--kmeans_max_iterations (-k)', '--refined_start (-r)', '--samplings (-S)', and '--percentage (-p)' parameters. If '--refined_start (-r)' is specified, then the Bradley-Fayyad refined start initialization will be used. This can often lead to better clustering results.
The 'diagonal_covariance' flag will cause the learned covariances to be diagonal matrices. This significantly simplifies the model itself and causes training to be faster, but restricts the ability to fit more complex GMMs.
If GMM training fails with an error indicating that a covariance matrix could not be inverted, make sure that the '--no_force_positive (-P)' parameter is not specified. Alternately, adding a small amount of Gaussian noise (using the '--noise (-N)' parameter) to the entire dataset may help prevent Gaussians with zero variance in a particular dimension, which is usually the cause of non-invertible covariance matrices.
The '--no_force_positive (-P)' parameter, if set, will avoid the checks after each iteration of the EM algorithm which ensure that the covariance matrices are positive definite. Specifying the flag can cause faster runtime, but may also cause non-positive definite covariance matrices, which will cause the program to crash.
As an example, to train a 6-Gaussian GMM on the data in 'data.csv' with a maximum of 100 iterations of EM and 3 trials, saving the trained GMM to ’gmm.bin', the following command can be used:
$ mlpack_gmm_train --input_file data.csv --gaussians 6 --trials 3 --output_model_file gmm.bin
To re-train that GMM on another set of data 'data2.csv', the following command may be used:
$ mlpack_gmm_train --input_model_file gmm.bin --input_file data2.csv --gaussians 6 --output_model_file new_gmm.bin
For further information, including relevant papers, citations, and theory, consult the documentation found at http://www.mlpack.org or included with your distribution of mlpack.
12 December 2020 | mlpack-3.4.2 |