pub struct GmmControl {
pub seed: u64,
pub max_iterations: usize,
pub tolerance: f64,
pub max_work: u64,
}Expand description
Deterministic convergence and work policy for Gaussian-mixture EM.
Fields§
§seed: u64Seed used by k-means++ mean initialization.
max_iterations: usizeMaximum number of accepted EM updates.
tolerance: f64Relative log-likelihood convergence tolerance.
max_work: u64Hard bound on initialization, responsibility, and parameter-update work.
Implementations§
Source§impl GmmControl
impl GmmControl
Sourcepub fn new(
seed: u64,
max_iterations: usize,
tolerance: f64,
max_work: u64,
) -> Result<Self, ClusteringError>
pub fn new( seed: u64, max_iterations: usize, tolerance: f64, max_work: u64, ) -> Result<Self, ClusteringError>
Builds checked EM control.
Examples found in repository?
examples/clustering_evidence.rs (line 41)
6fn main() {
7 let points = vec![
8 vec![-3.1, -3.0],
9 vec![-3.0, -2.9],
10 vec![-2.9, -3.1],
11 vec![4.9, 5.0],
12 vec![5.0, 5.1],
13 vec![5.1, 4.9],
14 ];
15 let kmeans = fit_kmeans(
16 &points,
17 2,
18 KMeansControl::new(4, 50, 1.0e-10, 20_000, 4).expect("control"),
19 )
20 .expect("bounded k-means");
21 let selected = &kmeans.restarts[kmeans.selected_restart];
22 println!(
23 "kmeans centroids={:?} inertia={:.6} selected={} restarts={} converged={} work={}",
24 kmeans.model.centroids,
25 selected.inertia,
26 kmeans.selected_restart,
27 kmeans.restarts.len(),
28 selected.converged,
29 kmeans.work
30 );
31
32 let gmm = fit_gmm(
33 &points,
34 GmmSpec::new(
35 2,
36 CovarianceType::Diagonal,
37 1.0e-6,
38 SingularComponentPolicy::default(),
39 )
40 .expect("spec"),
41 GmmControl::new(4, 50, 1.0e-9, 100_000).expect("control"),
42 )
43 .expect("regularized GMM");
44 println!(
45 "gmm means={:?} likelihood={:.6} iterations={} converged={} repairs={} aic={:.6} bic={:.6} work={}",
46 gmm.model.means,
47 gmm.evidence.log_likelihood,
48 gmm.evidence.iterations,
49 gmm.evidence.converged,
50 gmm.evidence.singular_component_repairs,
51 gmm.evidence.model_selection.aic,
52 gmm.evidence.model_selection.bic,
53 gmm.evidence.work
54 );
55}Trait Implementations§
Source§impl Clone for GmmControl
impl Clone for GmmControl
Source§fn clone(&self) -> GmmControl
fn clone(&self) -> GmmControl
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for GmmControl
Source§impl Debug for GmmControl
impl Debug for GmmControl
Source§impl Default for GmmControl
impl Default for GmmControl
Source§impl PartialEq for GmmControl
impl PartialEq for GmmControl
impl StructuralPartialEq for GmmControl
Auto Trait Implementations§
impl Freeze for GmmControl
impl RefUnwindSafe for GmmControl
impl Send for GmmControl
impl Sync for GmmControl
impl Unpin for GmmControl
impl UnsafeUnpin for GmmControl
impl UnwindSafe for GmmControl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more