Class KModes

All Implemented Interfaces:
Serializable, Comparable<CentroidClustering<int[],int[]>>

public class KModes extends CentroidClustering<int[],int[]>
K-Modes clustering. K-Modes is the binary equivalent for K-Means. The mean update for centroids is replaced by the mode one which is a majority vote among element of each cluster.

References

  1. Joshua Zhexue Huang. Clustering Categorical Data with k-Modes.
See Also:
  • Constructor Details

    • KModes

      public KModes(double distortion, int[][] centroids, int[] y)
      Constructor.
      Parameters:
      distortion - the total distortion.
      centroids - the centroids of each cluster.
      y - the cluster labels.
  • Method Details

    • distance

      protected double distance(int[] x, int[] y)
      Description copied from class: CentroidClustering
      The distance function.
      Specified by:
      distance in class CentroidClustering<int[],int[]>
      Parameters:
      x - an observation.
      y - the other observation.
      Returns:
      the distance.
    • fit

      public static KModes fit(int[][] data, int k)
      Fits k-modes clustering.
      Parameters:
      data - the input data of which each row is an observation.
      k - the number of clusters.
      Returns:
      the model.
    • fit

      public static KModes fit(int[][] data, int k, int maxIter)
      Fits k-modes clustering.
      Parameters:
      data - the input data of which each row is an observation.
      k - the number of clusters.
      maxIter - the maximum number of iterations.
      Returns:
      the model.