Class KMeans
java.lang.Object
ai.beestream.jitnn.ml.KMeans
k-means clustering with Lloyd's algorithm, after scikit-learn's KMeans: k-means++ seeding (or
given initial centres),
nInit restarts keeping the lowest inertia, and stopping when the
assignments no longer change or the centres move less than tol times the mean feature variance.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncentres()The cluster centres [k, features].Fits from k-means++ seeds.Fits from the given initial centres [k, d].floatinertia()Sum of squared distances of the training samples to their nearest centre.intThe iterations the kept run took.int[]Index of the nearest centre of each row.
-
Constructor Details
-
KMeans
public KMeans(int k, int maxIter, float tol, int nInit, long seed) k-means withkclusters, at mostmaxIteriterations per run, tolerancetol,nInitruns, seeding fromseed. -
KMeans
public KMeans(int k, long seed) k-means with scikit-learn's defaults: 300 iterations, tolerance 1e-4, one run.
-
-
Method Details
-
fit
-
fit
-
predict
Index of the nearest centre of each row. -
centres
The cluster centres [k, features]. -
inertia
public float inertia()Sum of squared distances of the training samples to their nearest centre. -
iterations
public int iterations()The iterations the kept run took.
-