pub struct KMeansParams<F: Float, R: Rng, D: Distance<F>>(_);
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 the tolerance 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 n_runs

Change the value of tolerance

Change the value of max_n_iterations

Change the value of init

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The checked hyperparameters
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
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.