Class EMeans

java.lang.Object
smile.clustering.EMeans

public class EMeans extends Object
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 B and initial step size alpha0 are automatically determined from the dataset size n, cluster count k, and epoch budget T without 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 tau times 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

  1. 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:
  • Field Details

    • DEFAULT_EPOCHS

      public static final double DEFAULT_EPOCHS
      Default number of training passes over the dataset.
      See Also:
  • Method Details

    • fit

      public static CentroidClustering<double[],double[]> fit(double[][] data, int k)
      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

      public static CentroidClustering<double[],double[]> fit(double[][] data, int k, double epochs)
      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 shared Clustering.Options. The maxIter parameter 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

      public static CentroidClustering<double[],double[]> fit(double[][] data, EMeans.Options options)
      Fits e-means clustering.
      Parameters:
      data - the input data of which each row is an observation.
      options - the hyperparameters.
      Returns:
      the model.
    • fit

      public static CentroidClustering<float[],float[]> fit(float[][] data, int k)
      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

      public static CentroidClustering<float[],float[]> fit(float[][] data, int k, double epochs)
      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

      public static CentroidClustering<float[],float[]> fit(float[][] data, Clustering.Options options)
      Fits e-means clustering on single-precision input data using shared Clustering.Options. The maxIter parameter 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

      public static CentroidClustering<float[],float[]> fit(float[][] data, EMeans.Options options)
      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.