pub struct KmeansBuilder { /* private fields */ }Expand description
A builder for k-means to provide control over parameters for the algorithm.
This allows one to tweak settings like the tolerance and the number of iterations.
§Examples
use cogset::{Euclid, KmeansBuilder};
let data = [Euclid([0.0, 0.0]),
Euclid([1.0, 0.5]),
Euclid([0.2, 0.2]),
Euclid([0.3, 0.8]),
Euclid([0.0, 1.0])];
let k = 3;
// we want the means extra precise.
let tol = 1e-12;
let kmeans = KmeansBuilder::new().tolerance(tol).kmeans(&data, k);
println!("{:?}", kmeans.clusters());Implementations§
Source§impl KmeansBuilder
impl KmeansBuilder
Sourcepub fn new() -> KmeansBuilder
pub fn new() -> KmeansBuilder
Create a default KmeansBuilder
Sourcepub fn tolerance(self, tol: f64) -> KmeansBuilder
pub fn tolerance(self, tol: f64) -> KmeansBuilder
Set the tolerance used to decide if the iteration has
converged to tol.
Sourcepub fn max_iter(self, max_iter: usize) -> KmeansBuilder
pub fn max_iter(self, max_iter: usize) -> KmeansBuilder
Set the maximum number of iterations to run before aborting to
max_iter.
Auto Trait Implementations§
impl Freeze for KmeansBuilder
impl RefUnwindSafe for KmeansBuilder
impl Send for KmeansBuilder
impl Sync for KmeansBuilder
impl Unpin for KmeansBuilder
impl UnwindSafe for KmeansBuilder
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