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, float[][] centroids) Constructs a KMeansPlusPlusFloatClusterer with the specified points and initial centroids.KMeansPlusPlusClusterer(float[][] points, int k) Constructs a KMeansPlusPlusFloatClusterer with the specified points and number of clusters. -
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.intfloat[][]
-
Constructor Details
-
KMeansPlusPlusClusterer
public KMeansPlusPlusClusterer(float[][] points, int k) Constructs a KMeansPlusPlusFloatClusterer with the specified points and number of clusters.- Parameters:
points- the points to cluster.k- number of clusters.
-
KMeansPlusPlusClusterer
public KMeansPlusPlusClusterer(float[][] points, float[][] centroids) Constructs a KMeansPlusPlusFloatClusterer with the specified points and initial centroids.The initial centroids provided as a parameter are copied before modification.
- Parameters:
points- the points to cluster.centroids- the initial centroids.
-
-
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. -
getCentroids
public float[][] getCentroids()
-