T
- the type of centroids.U
- the tpe of observations. Usually, T and U are the same.
But in case of SIB, they are different.public abstract class CentroidClustering<T,U> extends PartitionClustering implements java.lang.Comparable<CentroidClustering<T,U>>
Variations of k-means include restricting the centroids to members of the data set (k-medoids), choosing medians (k-medians clustering), choosing the initial centers less randomly (k-means++) or allowing a fuzzy cluster assignment (fuzzy c-means), etc.
Most k-means-type algorithms require the number of clusters to be specified in advance, which is considered to be one of the biggest drawbacks of these algorithms. Furthermore, the algorithms prefer clusters of approximately similar size, as they will always assign an object to the nearest centroid. This often leads to incorrectly cut borders of clusters (which is not surprising since the algorithm optimizes cluster centers, not cluster borders).
Modifier and Type | Field and Description |
---|---|
T[] |
centroids
The centroids of each cluster.
|
double |
distortion
The total distortion.
|
k, OUTLIER, size, y
Constructor and Description |
---|
CentroidClustering(double distortion,
T[] centroids,
int[] y)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(CentroidClustering<T,U> o) |
abstract double |
distance(T x,
U y)
The distance function.
|
int |
predict(U x)
Classifies a new observation.
|
java.lang.String |
toString() |
run, seed
public final double distortion
public final T[] centroids
public CentroidClustering(double distortion, T[] centroids, int[] y)
distortion
- the total distortion.centroids
- the centroids of each cluster.y
- the cluster labels.public int compareTo(CentroidClustering<T,U> o)
compareTo
in interface java.lang.Comparable<CentroidClustering<T,U>>
public int predict(U x)
x
- a new observation.public java.lang.String toString()
toString
in class PartitionClustering