pub struct GaussianMixtureModel {
pub cov_option: CovOption,
/* private fields */
}Expand description
A Gaussian Mixture Model
Fields§
§cov_option: CovOptionThe covariance options for the GMM.
Implementations§
Source§impl GaussianMixtureModel
impl GaussianMixtureModel
Sourcepub fn new(k: usize) -> GaussianMixtureModel
pub fn new(k: usize) -> GaussianMixtureModel
Constructs a new Gaussian Mixture Model
Defaults to 100 maximum iterations and full covariance structure.
§Examples
use rusty_machine::learning::gmm::GaussianMixtureModel;
let gmm = GaussianMixtureModel::new(3);Sourcepub fn with_weights(
k: usize,
mixture_weights: Vector<f64>,
) -> LearningResult<GaussianMixtureModel>
pub fn with_weights( k: usize, mixture_weights: Vector<f64>, ) -> LearningResult<GaussianMixtureModel>
Constructs a new GMM with the specified prior mixture weights.
The mixture weights must have the same length as the number of components. Each element of the mixture weights must be non-negative.
§Examples
use rusty_machine::learning::gmm::GaussianMixtureModel;
use rusty_machine::linalg::Vector;
let mix_weights = Vector::new(vec![0.25, 0.25, 0.5]);
let gmm = GaussianMixtureModel::with_weights(3, mix_weights).unwrap();§Failures
Fails if either of the following conditions are met:
- Mixture weights do not have length k.
- Mixture weights have a negative entry.
Sourcepub fn means(&self) -> Option<&Matrix<f64>>
pub fn means(&self) -> Option<&Matrix<f64>>
The model means
Returns an Option<&Matrix
Sourcepub fn covariances(&self) -> Option<&Vec<Matrix<f64>>>
pub fn covariances(&self) -> Option<&Vec<Matrix<f64>>>
The model covariances
Returns an Option<&Vec<Matrix
Sourcepub fn mixture_weights(&self) -> &Vector<f64>
pub fn mixture_weights(&self) -> &Vector<f64>
The model mixture weights
Returns a reference to the model mixture weights. These are the weighted contributions of each underlying Gaussian to the model distribution.
Sourcepub fn set_max_iters(&mut self, iters: usize)
pub fn set_max_iters(&mut self, iters: usize)
Sets the max number of iterations for the EM algorithm.
§Examples
use rusty_machine::learning::gmm::GaussianMixtureModel;
let mut gmm = GaussianMixtureModel::new(2);
gmm.set_max_iters(5);