Package smile.clustering
Class KModes
java.lang.Object
smile.clustering.PartitionClustering
smile.clustering.CentroidClustering<int[],int[]>
smile.clustering.KModes
- All Implemented Interfaces:
Serializable,Comparable<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
- Joshua Zhexue Huang. Clustering Categorical Data with k-Modes.
- See Also:
-
Field Summary
Fields inherited from class smile.clustering.CentroidClustering
centroids, distortionFields inherited from class smile.clustering.PartitionClustering
k, OUTLIER, size, y -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class smile.clustering.CentroidClustering
compareTo, predict, toStringMethods inherited from class smile.clustering.PartitionClustering
run, seed
-
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:CentroidClusteringThe distance function.- Specified by:
distancein classCentroidClustering<int[],int[]> - Parameters:
x- an observation.y- the other observation.- Returns:
- the distance.
-
fit
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
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.
-