Class EMeans
java.lang.Object
smile.clustering.EMeans
E-Means clustering. E-Means is a mini-batch exponential moving average (EMA)
optimization procedure for the k-means objective that converges to lower
distortion than Lloyd's algorithm in roughly one-tenth the passes over the
dataset.
For each cluster j, E-Means maintains an exponentially decayed count
N_j and sum S_j, reading off the centroid as
c_j = S_j / N_j:
N_j <- (1 - alpha) * N_j + alpha * n_j
S_j <- (1 - alpha) * S_j + alpha * s_j
where n_j and s_j are the batch count and sum assigned to
cluster j, and alpha is annealed on a cosine schedule from
an initial peak alpha0 down to 0.1 * alpha0.
E-Means combines four key mechanisms:
- Automatic scaling laws: The mini-batch size
Band initial step sizealpha0are automatically determined from the dataset sizen, cluster countk, and epoch budgetTwithout hyperparameter tuning. - Cosine step-size schedule: Progressively stabilizes centroid movement across mini-batch updates.
- Dead-cluster revival: Every 5 mini-batches, clusters whose EMA
mass falls below
tautimes the mean mass are revived by splitting active donor clusters sampled in proportion to their mass. - Last-epoch-mean finalization: In the closing pass over the data, each centroid is set to the exact unweighted mean of the points assigned to it during that pass.
References
- Swann Bessa, Pierre-Emmanuel Mazaré, Gergely Szilvasy, Hugo Touvron, David Picard, Matthijs Douze, and Hervé Jégou. e-means: outperforming k-means (in one-tenth the epochs). arXiv:2611.09501, 2026.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumScaling law mode for selecting the mini-batch sizeB.static final recordE-Means clustering hyperparameters. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault number of training passes over the dataset. -
Method Summary
Modifier and TypeMethodDescriptionstatic CentroidClustering<double[], double[]> fit(double[][] data, int k) Fits e-means clustering with the default 5 epochs.static CentroidClustering<double[], double[]> fit(double[][] data, int k, double epochs) Fits e-means clustering.static CentroidClustering<double[], double[]> fit(double[][] data, Clustering.Options options) Fits e-means clustering using sharedClustering.Options.static CentroidClustering<double[], double[]> fit(double[][] data, EMeans.Options options) Fits e-means clustering.static CentroidClustering<float[], float[]> fit(float[][] data, int k) Fits e-means clustering on single-precision input data with the default 5 epochs.static CentroidClustering<float[], float[]> fit(float[][] data, int k, double epochs) Fits e-means clustering on single-precision input data.static CentroidClustering<float[], float[]> fit(float[][] data, Clustering.Options options) Fits e-means clustering on single-precision input data using sharedClustering.Options.static CentroidClustering<float[], float[]> fit(float[][] data, EMeans.Options options) Fits e-means clustering on single-precision input data.
-
Field Details
-
DEFAULT_EPOCHS
public static final double DEFAULT_EPOCHSDefault number of training passes over the dataset.- See Also:
-
-
Method Details
-
fit
Fits e-means clustering with the default 5 epochs.- Parameters:
data- the input data of which each row is an observation.k- the number of clusters.- Returns:
- the model.
-
fit
Fits e-means clustering.- Parameters:
data- the input data of which each row is an observation.k- the number of clusters.epochs- the number of training passes over the dataset.- Returns:
- the model.
-
fit
public static CentroidClustering<double[],double[]> fit(double[][] data, Clustering.Options options) Fits e-means clustering using sharedClustering.Options. ThemaxIterparameter is used as the number of epochs.- Parameters:
data- the input data of which each row is an observation.options- the clustering hyperparameters.- Returns:
- the model.
-
fit
Fits e-means clustering.- Parameters:
data- the input data of which each row is an observation.options- the hyperparameters.- Returns:
- the model.
-
fit
Fits e-means clustering on single-precision input data with the default 5 epochs.- Parameters:
data- the input data of which each row is an observation.k- the number of clusters.- Returns:
- the model.
-
fit
Fits e-means clustering on single-precision input data.- Parameters:
data- the input data of which each row is an observation.k- the number of clusters.epochs- the number of training passes over the dataset.- Returns:
- the model.
-
fit
Fits e-means clustering on single-precision input data using sharedClustering.Options. ThemaxIterparameter is used as the number of epochs.- Parameters:
data- the input data of which each row is an observation.options- the clustering hyperparameters.- Returns:
- the model.
-
fit
Fits e-means clustering on single-precision input data.- Parameters:
data- the input data of which each row is an observation.options- the hyperparameters.- Returns:
- the model.
-