pub struct KMeansConfig {
pub k: usize,
pub max_iters: usize,
pub tol: f64,
pub seed: u64,
pub max_points_per_centroid: Option<usize>,
pub chunk_size_data: usize,
pub chunk_size_centroids: usize,
pub verbose: bool,
}Expand description
Configuration for the FastKMeans algorithm
Fields§
§k: usizeNumber of clusters
max_iters: usizeMaximum number of iterations
tol: f64Convergence tolerance. When centroid shift is below this threshold, the algorithm stops early. Set to negative value to disable early stopping.
seed: u64Random seed for centroid initialization and subsampling
max_points_per_centroid: Option<usize>Maximum points per centroid for subsampling. If n_samples > k * max_points_per_centroid, data will be subsampled. Set to None to disable subsampling.
chunk_size_data: usizeChunk size for data processing. Larger values use more memory but may be faster.
chunk_size_centroids: usizeChunk size for centroid processing. Larger values use more memory but may be faster.
verbose: boolPrint verbose output during training
Implementations§
Source§impl KMeansConfig
impl KMeansConfig
Sourcepub fn new(k: usize) -> KMeansConfig
pub fn new(k: usize) -> KMeansConfig
Create a new configuration with the specified number of clusters
Sourcepub fn with_max_iters(self, max_iters: usize) -> KMeansConfig
pub fn with_max_iters(self, max_iters: usize) -> KMeansConfig
Set the maximum number of iterations
Sourcepub fn with_tol(self, tol: f64) -> KMeansConfig
pub fn with_tol(self, tol: f64) -> KMeansConfig
Set the convergence tolerance
Sourcepub fn with_seed(self, seed: u64) -> KMeansConfig
pub fn with_seed(self, seed: u64) -> KMeansConfig
Set the random seed
Sourcepub fn with_max_points_per_centroid(
self,
max_ppc: Option<usize>,
) -> KMeansConfig
pub fn with_max_points_per_centroid( self, max_ppc: Option<usize>, ) -> KMeansConfig
Set the maximum points per centroid (for subsampling)
Sourcepub fn with_verbose(self, verbose: bool) -> KMeansConfig
pub fn with_verbose(self, verbose: bool) -> KMeansConfig
Set verbose mode
Sourcepub fn with_chunk_size_data(self, chunk_size: usize) -> KMeansConfig
pub fn with_chunk_size_data(self, chunk_size: usize) -> KMeansConfig
Set the data chunk size
Sourcepub fn with_chunk_size_centroids(self, chunk_size: usize) -> KMeansConfig
pub fn with_chunk_size_centroids(self, chunk_size: usize) -> KMeansConfig
Set the centroid chunk size
Trait Implementations§
Source§impl Clone for KMeansConfig
impl Clone for KMeansConfig
Source§fn clone(&self) -> KMeansConfig
fn clone(&self) -> KMeansConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KMeansConfig
impl Debug for KMeansConfig
Source§impl Default for KMeansConfig
impl Default for KMeansConfig
Source§fn default() -> KMeansConfig
fn default() -> KMeansConfig
Auto Trait Implementations§
impl Freeze for KMeansConfig
impl RefUnwindSafe for KMeansConfig
impl Send for KMeansConfig
impl Sync for KMeansConfig
impl Unpin for KMeansConfig
impl UnwindSafe for KMeansConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more