Package smile.clustering.linkage
Class SingleLinkage
java.lang.Object
smile.clustering.linkage.Linkage
smile.clustering.linkage.SingleLinkage
Single linkage. The distance between groups is defined as the distance
between the closest pair of objects, one from each group.
A drawback of this method is the so-called chaining phenomenon: clusters
may be forced together due to single elements being close to each other,
even though many of the elements in each cluster may be very distant to
each other.
Single linkage clustering is essentially the same as Kruskal's algorithm for minimum spanning trees. However, in single linkage clustering, the order in which clusters are formed is important, while for minimum spanning trees what matters is the set of pairs of points that form distances chosen by the algorithm.
-
Constructor Summary
ConstructorDescriptionSingleLinkage
(double[][] proximity) Constructor.SingleLinkage
(int size, float[] proximity) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
merge
(int i, int j) Merges two clusters into one and update the proximity matrix.static SingleLinkage
of
(double[][] data) Computes the proximity and the linkage.static <T> SingleLinkage
Computes the proximity and the linkage.toString()
-
Constructor Details
-
SingleLinkage
public SingleLinkage(double[][] proximity) Constructor.- Parameters:
proximity
- the proximity matrix. Only the lower half will be referred.
-
SingleLinkage
public SingleLinkage(int size, float[] proximity) Constructor. Initialize the linkage with the lower triangular proximity matrix.- Parameters:
size
- the data size.proximity
- the column-wise linearized proximity matrix that stores only the lower half. The length of proximity should be size * (size+1) / 2. To save space, Linkage will use this argument directly without copy. The elements may be modified.
-
-
Method Details
-
of
Computes the proximity and the linkage.- Parameters:
data
- the data points.- Returns:
- the linkage.
-
of
Computes the proximity and the linkage.- Type Parameters:
T
- the data type of points.- Parameters:
data
- the data points.distance
- the distance function.- Returns:
- the linkage.
-
toString
-
merge
public void merge(int i, int j) Description copied from class:Linkage
Merges two clusters into one and update the proximity matrix.
-