[][src]Function rkm::kmeans_lloyd_with_config

pub fn kmeans_lloyd_with_config<V: Value>(
    data: &ArrayView2<V>,
    k: usize,
    config: &Config<V>
) -> (Array2<V>, Vec<usize>)

Calculate means and cluster assignments for the given data and number of clusters (k). Returns a tuple containing the means (as a 2D ndarray) and a Vec of indices that map into the means ndarray and correspond elementwise to each input data point to give the cluster assignments for each data point. Takes a Config object which can be used to optionally specify:

  • Random number seed (for initialization)
  • Maximum number of iterations
  • Minimum mean delta distance The algorithm will terminate when convergence is reached, or the number of iterations equals the maximum, or none of the means change by at least the minimum delta distance.