Class KMeansPlusPlusClusterer

java.lang.Object
io.github.jbellis.jvector.pq.KMeansPlusPlusClusterer

public class KMeansPlusPlusClusterer extends Object
A KMeans++ implementation for float vectors. Optimizes to use SIMD vector instructions if available.
  • Constructor Summary

    Constructors
    Constructor
    Description
    KMeansPlusPlusClusterer(float[][] points, int k, BiFunction<float[],float[],Float> distanceFunction)
    Constructs a KMeansPlusPlusFloatClusterer with the specified number of clusters, maximum iterations, and distance function.
  • Method Summary

    Modifier and Type
    Method
    Description
    static float[]
    centroidOf(List<float[]> points)
    Computes the centroid of a list of points.
    float[][]
    cluster(int maxIterations)
    Performs clustering on the provided set of points.
    int
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • KMeansPlusPlusClusterer

      public KMeansPlusPlusClusterer(float[][] points, int k, BiFunction<float[],float[],Float> distanceFunction)
      Constructs a KMeansPlusPlusFloatClusterer with the specified number of clusters, maximum iterations, and distance function.
      Parameters:
      k - number of clusters.
      distanceFunction - a function to compute the distance between two points.
  • Method Details

    • cluster

      public float[][] cluster(int maxIterations)
      Performs clustering on the provided set of points.
      Returns:
      an array of cluster centroids.
    • clusterOnce

      public int clusterOnce()
    • centroidOf

      public static float[] centroidOf(List<float[]> points)
      Computes the centroid of a list of points.