Single-linkage clustering
In statistics, single-linkage clustering is one of several methods of hierarchical clustering. It is based on grouping clusters in bottom-up fashion (agglomerative clustering), at each step combining two clusters that contain the closest pair of elements not yet belonging to the same cluster as each other.
This method tends to produce long thin clusters in which nearby elements of the same cluster have small distances, but elements at opposite ends of a cluster may be much farther from each other than two elements of other clusters. For some classes of data, this may lead to difficulties in defining classes that could usefully subdivide the data.[1] However, it is popular in astronomy for analyzing galaxy clusters, which may often involve long strings of matter; in this application, it is also known as the friends-of-friends algorithm.[2]
Overview of agglomerative clustering methods
In the beginning of the agglomerative clustering process, each element is in a cluster of its own. The clusters are then sequentially combined into larger clusters, until all elements end up being in the same cluster. At each step, the two clusters separated by the shortest distance are combined. The function used to determine the distance between two clusters, known as the linkage function, is what differentiates the agglomerative clustering methods.
In single-linkage clustering, the distance between two clusters is determined by a single pair of elements: those two elements (one in each cluster) that are closest to each other. The shortest of these pairwise distances that remain at any step causes the two clusters whose elements are involved to be merged. The method is also known as nearest neighbour clustering. The result of the clustering can be visualized as a dendrogram, which shows the sequence in which clusters were merged and the distance at which each merge took place.[3]
Mathematically, the linkage function – the distance D(X,Y) between clusters X and Y – is described by the expression
- [math]\displaystyle{ D(X,Y)=\min_{x\in X, y\in Y} d(x,y), }[/math]
where X and Y are any two sets of elements considered as clusters, and d(x,y) denotes the distance between the two elements x and y.
Naive algorithm
The following algorithm is an agglomerative scheme that erases rows and columns in a proximity matrix as old clusters are merged into new ones. The [math]\displaystyle{ N \times N }[/math] proximity matrix [math]\displaystyle{ D }[/math] contains all distances [math]\displaystyle{ d(i,j) }[/math]. The clusterings are assigned sequence numbers [math]\displaystyle{ 0,1, \ldots, n-1 }[/math] and [math]\displaystyle{ L(k) }[/math] is the level of the [math]\displaystyle{ k }[/math]-th clustering. A cluster with sequence number m is denoted (m) and the proximity between clusters [math]\displaystyle{ (r) }[/math] and [math]\displaystyle{ (s) }[/math] is denoted [math]\displaystyle{ d[(r),(s)] }[/math].
The single linkage algorithm is composed of the following steps:
- Begin with the disjoint clustering having level [math]\displaystyle{ L(0) = 0 }[/math] and sequence number [math]\displaystyle{ m=0 }[/math].
- Find the most similar pair of clusters in the current clustering, say pair [math]\displaystyle{ (r), (s) }[/math], according to [math]\displaystyle{ d[(r),(s)] = \min d[(i),(j)] }[/math]where the minimum is over all pairs of clusters in the current clustering.
- Increment the sequence number: [math]\displaystyle{ m = m + 1 }[/math]. Merge clusters [math]\displaystyle{ (r) }[/math] and [math]\displaystyle{ (s) }[/math] into a single cluster to form the next clustering [math]\displaystyle{ m }[/math]. Set the level of this clustering to [math]\displaystyle{ L(m) = d[(r),(s)] }[/math]
- Update the proximity matrix, [math]\displaystyle{ D }[/math], by deleting the rows and columns corresponding to clusters [math]\displaystyle{ (r) }[/math] and [math]\displaystyle{ (s) }[/math] and adding a row and column corresponding to the newly formed cluster. The proximity between the new cluster, denoted [math]\displaystyle{ (r,s) }[/math] and an old cluster [math]\displaystyle{ (k) }[/math] is defined as [math]\displaystyle{ d[(r,s),(k)] = \min \{d[(k),(r)], d[(k),(s)] \} }[/math].
- If all objects are in one cluster, stop. Else, go to step 2.
Working example
This working example is based on a JC69 genetic distance matrix computed from the 5S ribosomal RNA sequence alignment of five bacteria: Bacillus subtilis ([math]\displaystyle{ a }[/math]), Bacillus stearothermophilus ([math]\displaystyle{ b }[/math]), Lactobacillus viridescens ([math]\displaystyle{ c }[/math]), Acholeplasma modicum ([math]\displaystyle{ d }[/math]), and Micrococcus luteus ([math]\displaystyle{ e }[/math]).[4][5]
First step
- First clustering
Let us assume that we have five elements [math]\displaystyle{ (a,b,c,d,e) }[/math] and the following matrix [math]\displaystyle{ D_1 }[/math] of pairwise distances between them:
a | b | c | d | e | |
---|---|---|---|---|---|
a | 0 | 17 | 21 | 31 | 23 |
b | 17 | 0 | 30 | 34 | 21 |
c | 21 | 30 | 0 | 28 | 39 |
d | 31 | 34 | 28 | 0 | 43 |
e | 23 | 21 | 39 | 43 | 0 |
In this example, [math]\displaystyle{ D_1 (a,b)=17 }[/math] is the lowest value of [math]\displaystyle{ D_1 }[/math], so we cluster elements a and b.
- First branch length estimation
Let u denote the node to which a and b are now connected. Setting [math]\displaystyle{ \delta(a,u)=\delta(b,u)=D_1(a,b)/2 }[/math] ensures that elements a and b are equidistant from u. This corresponds to the expectation of the ultrametricity hypothesis. The branches joining a and b to u then have lengths [math]\displaystyle{ \delta(a,u)=\delta(b,u)=17/2=8.5 }[/math] (see the final dendrogram)
- First distance matrix update
We then proceed to update the initial proximity matrix [math]\displaystyle{ D_1 }[/math] into a new proximity matrix [math]\displaystyle{ D_2 }[/math] (see below), reduced in size by one row and one column because of the clustering of a with b. Bold values in [math]\displaystyle{ D_2 }[/math] correspond to the new distances, calculated by retaining the minimum distance between each element of the first cluster [math]\displaystyle{ (a,b) }[/math] and each of the remaining elements:
- [math]\displaystyle{ \begin{array}{lllllll} D_2((a,b),c)&=&\min(D_1(a,c),D_1(b,c))&=&\min(21,30)&=&21 \\ D_2((a,b),d)&=&\min(D_1(a,d),D_1(b,d))&=&\min(31,34)&=&31 \\ D_2((a,b),e)&=&\min(D_1(a,e),D_1(b,e))&=&\min(23,21)&=&21 \end{array} }[/math]
Italicized values in [math]\displaystyle{ D_2 }[/math] are not affected by the matrix update as they correspond to distances between elements not involved in the first cluster.
Second step
- Second clustering
We now reiterate the three previous actions, starting from the new distance matrix [math]\displaystyle{ D_2 }[/math] :
(a,b) | c | d | e | |
---|---|---|---|---|
(a,b) | 0 | 21 | 31 | 21 |
c | 21 | 0 | 28 | 39 |
d | 31 | 28 | 0 | 43 |
e | 21 | 39 | 43 | 0 |
Here, [math]\displaystyle{ D_2 ((a,b),c)=21 }[/math] and [math]\displaystyle{ D_2 ((a,b),e)=21 }[/math] are the lowest values of [math]\displaystyle{ D_2 }[/math], so we join cluster [math]\displaystyle{ (a,b) }[/math] with element c and with element e.
- Second branch length estimation
Let v denote the node to which [math]\displaystyle{ (a,b) }[/math], c and e are now connected. Because of the ultrametricity constraint, the branches joining a or b to v, and c to v, and also e to v are equal and have the following total length:
- [math]\displaystyle{ \delta(a,v)=\delta(b,v)=\delta(c,v)=\delta(e,v)=21/2=10.5 }[/math]
We deduce the missing branch length:
- [math]\displaystyle{ \delta(u,v)=\delta(c,v)-\delta(a,u)=\delta(c,v)-\delta(b,u)=10.5-8.5=2 }[/math] (see the final dendrogram)
- Second distance matrix update
We then proceed to update the [math]\displaystyle{ D_2 }[/math] matrix into a new distance matrix [math]\displaystyle{ D_3 }[/math] (see below), reduced in size by two rows and two columns because of the clustering of [math]\displaystyle{ (a,b) }[/math] with c and with e :
- [math]\displaystyle{ D_3(((a,b),c,e),d)=\min(D_2((a,b),d),D_2(c,d),D_2(e,d))=\min(31,28,43)=28 }[/math]
Final step
The final [math]\displaystyle{ D_3 }[/math] matrix is:
((a,b),c,e) | d | |
---|---|---|
((a,b),c,e) | 0 | 28 |
d | 28 | 0 |
So we join clusters [math]\displaystyle{ ((a,b),c,e) }[/math] and [math]\displaystyle{ d }[/math].
Let [math]\displaystyle{ r }[/math] denote the (root) node to which [math]\displaystyle{ ((a,b),c,e) }[/math] and [math]\displaystyle{ d }[/math] are now connected. The branches joining [math]\displaystyle{ ((a,b),c,e) }[/math] and [math]\displaystyle{ d }[/math] to [math]\displaystyle{ r }[/math] then have lengths:
[math]\displaystyle{ \delta(((a,b),c,e),r)=\delta(d,r)=28/2=14 }[/math]
We deduce the remaining branch length:
[math]\displaystyle{ \delta(v,r)=\delta(a,r)-\delta(a,v)=\delta(b,r)-\delta(b,v)=\delta(c,r)-\delta(c,v)=\delta(e,r)-\delta(e,v)=14-10.5=3.5 }[/math]
The single-linkage dendrogram
The dendrogram is now complete. It is ultrametric because all tips ([math]\displaystyle{ a }[/math], [math]\displaystyle{ b }[/math], [math]\displaystyle{ c }[/math], [math]\displaystyle{ e }[/math], and [math]\displaystyle{ d }[/math]) are equidistant from [math]\displaystyle{ r }[/math] :
[math]\displaystyle{ \delta(a,r)=\delta(b,r)=\delta(c,r)=\delta(e,r)=\delta(d,r)=14 }[/math]
The dendrogram is therefore rooted by [math]\displaystyle{ r }[/math], its deepest node.
Other linkages
The naive algorithm for 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.
Alternative linkage schemes include complete linkage clustering, average linkage clustering (UPGMA and WPGMA), and Ward's method. In the naive algorithm for agglomerative clustering, implementing a different linkage scheme may be accomplished simply by using a different formula to calculate inter-cluster distances in the algorithm. The formula that should be adjusted has been highlighted using bold text in the above algorithm description. However, more efficient algorithms such as the one described below do not generalize to all linkage schemes in the same way.
Single-linkage clustering | Complete-linkage clustering | Average linkage clustering: WPGMA | Average linkage clustering: UPGMA |
Faster algorithms
The naive algorithm for single-linkage clustering is easy to understand but slow, with time complexity [math]\displaystyle{ O(n^3) }[/math].[6] In 1973, R. Sibson proposed an algorithm with time complexity [math]\displaystyle{ O(n^2) }[/math] and space complexity [math]\displaystyle{ O(n) }[/math] (both optimal) known as SLINK. The slink algorithm represents a clustering on a set of [math]\displaystyle{ n }[/math] numbered items by two functions. These functions are both determined by finding the smallest cluster [math]\displaystyle{ C }[/math] that contains both item [math]\displaystyle{ i }[/math] and at least one larger-numbered item. The first function, [math]\displaystyle{ \pi }[/math], maps item [math]\displaystyle{ i }[/math] to the largest-numbered item in cluster [math]\displaystyle{ C }[/math]. The second function, [math]\displaystyle{ \lambda }[/math], maps item [math]\displaystyle{ i }[/math] to the distance associated with the creation of cluster [math]\displaystyle{ C }[/math]. Storing these functions in two arrays that map each item number to its function value takes space [math]\displaystyle{ O(n) }[/math], and this information is sufficient to determine the clustering itself. As Sibson shows, when a new item is added to the set of items, the updated functions representing the new single-linkage clustering for the augmented set, represented in the same way, can be constructed from the old clustering in time [math]\displaystyle{ O(n) }[/math]. The SLINK algorithm then loops over the items, one by one, adding them to the representation of the clustering.[7][8]
An alternative algorithm, running in the same optimal time and space bounds, is based on the equivalence between the naive algorithm and Kruskal's algorithm for minimum spanning trees. Instead of using Kruskal's algorithm, one can use Prim's algorithm, in a variation without binary heaps that takes time [math]\displaystyle{ O(n^2) }[/math] and space [math]\displaystyle{ O(n) }[/math] to construct the minimum spanning tree (but not the clustering) of the given items and distances. Then, applying Kruskal's algorithm to the sparse graph formed by the edges of the minimum spanning tree produces the clustering itself in an additional time [math]\displaystyle{ O(n\log n) }[/math] and space [math]\displaystyle{ O(n) }[/math].[9]
See also
- Cluster analysis
- Complete-linkage clustering
- Hierarchical clustering
- Molecular clock
- Neighbor-joining
- UPGMA
- WPGMA
References
- ↑ Everitt, Brian (2011). Cluster analysis. Chichester, West Sussex, U.K: Wiley. ISBN 9780470749913.
- ↑ Feigelson, Eric (2012). "Classification in astronomy: past and present". in Way, Michael J.; Scargle, Jeffrey D.; Ali, Kamal M. et al.. Advances in Machine Learning and Data Mining for Astronomy. Chapman and Hall/CRC. pp. 3–10. doi:10.1201/b11822-7. Bibcode: 2012amld.book....3F.
- ↑ Numerical Ecology. Developments in Environmental Modelling. 20 (Second English ed.). Amsterdam: Elsevier. 1998.
- ↑ "Collection of published 5S, 5.8S and 4.5S ribosomal RNA sequences". Nucleic Acids Research 14 Suppl (Suppl): r1-59. 1986. doi:10.1093/nar/14.suppl.r1. PMID 2422630.
- ↑ Noller, Harry F. Jr.; Moldave, Kivie, eds (1988). "Phylogenetic analysis using ribosomal RNA". Ribosomes. Methods in Enzymology. 164. pp. 793–812. doi:10.1016/s0076-6879(88)64084-5.
- ↑ Murtagh, Fionn; Contreras, Pedro (2012). "Algorithms for hierarchical clustering: an overview". Wiley Interdisciplinary Reviews: Data Mining and Knowledge Discovery (Wiley Online Library) 2 (1): 86–97. doi:10.1002/widm.53.
- ↑ "SLINK: an optimally efficient algorithm for the single-link cluster method". The Computer Journal (British Computer Society) 16 (1): 30–34. 1973. doi:10.1093/comjnl/16.1.30. http://www.cs.gsu.edu/~wkim/index_files/papers/sibson.pdf.
- ↑ Gan, Guojun (2007). Data clustering : theory, algorithms, and applications. Philadelphia, Pa. Alexandria, Va: SIAM, Society for Industrial and Applied Mathematics American Statistical Association. ISBN 9780898716238.
- ↑ "Minimum spanning trees and single linkage cluster analysis". Journal of the Royal Statistical Society, Series C 18 (1): 54–64. 1969. doi:10.2307/2346439..
External links
Original source: https://en.wikipedia.org/wiki/Single-linkage clustering.
Read more |