Package smile.clustering.linkage
Class Linkage
java.lang.Object
smile.clustering.linkage.Linkage
- Direct Known Subclasses:
CompleteLinkage
,SingleLinkage
,UPGMALinkage
,UPGMCLinkage
,WardLinkage
,WPGMALinkage
,WPGMCLinkage
A measure of dissimilarity between clusters (i.e. sets of observations).
References
- Anil K. Jain, Richard C. Dubes. Algorithms for clustering data. 1988.
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfloat
d
(int i, int j) Returns the distance/dissimilarity between two clusters/objects, which are indexed by integers.abstract void
merge
(int i, int j) Merges two clusters into one and update the proximity matrix.static float[]
proximity
(double[][] data) Computes the proximity matrix (linearized in column major) based on Euclidean distance.static <T> float[]
Computes the proximity matrix (linearized in column major).int
size()
Returns the proximity matrix size.
-
Constructor Details
-
Linkage
public Linkage(double[][] proximity) Constructor.- Parameters:
proximity
- the proximity matrix. Only the lower half will be referred.
-
Linkage
public Linkage(int size, float[] proximity) Constructor.- 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
-
size
public int size()Returns the proximity matrix size.- Returns:
- the proximity matrix size.
-
d
public float d(int i, int j) Returns the distance/dissimilarity between two clusters/objects, which are indexed by integers.- Parameters:
i
- the row index of proximity matrix.j
- the column index of proximity matrix.- Returns:
- the distance/dissimilarity.
-
merge
public abstract void merge(int i, int j) Merges two clusters into one and update the proximity matrix.- Parameters:
i
- cluster id.j
- cluster id.
-
proximity
public static float[] proximity(double[][] data) Computes the proximity matrix (linearized in column major) based on Euclidean distance.- Parameters:
data
- the data points.- Returns:
- the linearized proximity matrix based on Eulidean distance.
-
proximity
Computes the proximity matrix (linearized in column major).- Type Parameters:
T
- the data type of points.- Parameters:
data
- the data points.distance
- the distance function.- Returns:
- the linearized proximity matrix.
-