Package io.github.jbellis.jvector.pq
Class KMeansPlusPlusClusterer
java.lang.Object
io.github.jbellis.jvector.pq.KMeansPlusPlusClusterer
A KMeans++ implementation for float vectors. Optimizes to use SIMD vector instructions if available.
-
Constructor Summary
ConstructorsConstructorDescriptionKMeansPlusPlusClusterer(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 TypeMethodDescriptionstatic 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
-
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
Computes the centroid of a list of points.
-