Struct linfa_clustering::KMeansParams [−][src]
Expand description
An helper struct used to construct a set of valid hyperparameters for the K-means algorithm (using the builder pattern).
Implementations
new
lets us configure our training algorithm parameters:
- we will be looking for
n_clusters
in the training dataset; - the training is considered complete if the euclidean distance
between the old set of centroids and the new set of centroids
after a training iteration is lower or equal than
tolerance
; - we exit the training loop when the number of training iterations
exceeds
max_n_iterations
even if thetolerance
convergence condition has not been met. - As KMeans convergence depends on centroids initialization
we run the algorithm
n_runs
times and we keep the best outputs in terms of inertia that the ones which minimizes the sum of squared euclidean distances to the closest centroid for all observations.
Defaults are provided if optional parameters are not specified:
tolerance = 1e-4
max_n_iterations = 300
n_runs = 10
init = KMeansPlusPlus
Change the value of max_n_iterations
Change the value of init
Trait Implementations
type Checked = KMeansValidParams<F, R, D>
type Checked = KMeansValidParams<F, R, D>
The checked hyperparameters
type Error = KMeansParamsError
type Error = KMeansParamsError
Error type resulting from failed hyperparameter checking
Checks the hyperparameters and returns a reference to the checked hyperparameters if successful Read more
Checks the hyperparameters and returns the checked hyperparameters if successful
Calls check()
and unwraps the result