pub struct KMeans { /* private fields */ }Expand description
Lloyd’s k-means with k-means++ seeding: alternately assign each point to its nearest centroid
and move each centroid to the mean of its points, minimising the within-cluster sum of squared
distances (the inertia). The run is repeated n_init times from different seedings and the
lowest-inertia result kept, because the algorithm only finds a local optimum. A cluster that
loses all its points is re-seeded at the point farthest from its centroid.
Implementations§
Source§impl KMeans
impl KMeans
pub fn new(k: usize, seed: u64) -> Self
pub fn with_restarts(self, n_init: usize) -> Self
pub fn with_limits(self, max_iterations: usize, tolerance: f64) -> Self
pub fn centroids(&self) -> &R2D
Sourcepub fn inertia(&self) -> f64
pub fn inertia(&self) -> f64
The sum of squared distances from each point to its centroid, for the best restart.
Sourcepub fn iterations(&self) -> usize
pub fn iterations(&self) -> usize
Lloyd iterations used by the best restart.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for KMeans
impl RefUnwindSafe for KMeans
impl Send for KMeans
impl Sync for KMeans
impl Unpin for KMeans
impl UnsafeUnpin for KMeans
impl UnwindSafe for KMeans
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