Hierarchical clustering


In data mining and statistics, hierarchical clustering is a method of cluster analysis which seeks to build a hierarchy of clusters. Strategies for hierarchical clustering generally fall into two types:
In general, the merges and splits are determined in a greedy manner. The results of hierarchical clustering are usually presented in a dendrogram.
The standard algorithm for hierarchical agglomerative clustering has a time complexity of and requires memory, which makes it too slow for even medium data sets. However, for some special cases, optimal efficient agglomerative methods are known: SLINK for single-linkage and CLINK for complete-linkage clustering. With a heap the runtime of the general case can be reduced to at the cost of further increasing the memory requirements. In many cases, the memory overheads of this approach are too large to make it practically usable.
Except for the special case of single-linkage, none of the algorithms can be guaranteed to find the optimum solution.
Divisive clustering with an exhaustive search is, but it is common to use faster heuristics to choose splits, such as k-means.

Cluster dissimilarity

In order to decide which clusters should be combined, or where a cluster should be split, a measure of dissimilarity between sets of observations is required. In most methods of hierarchical clustering, this is achieved by use of an appropriate metric, and a linkage criterion which specifies the dissimilarity of sets as a function of the pairwise distances of observations in the sets.

Metric

The choice of an appropriate metric will influence the shape of the clusters, as some elements may be close to one another according to one distance and farther away according to another. For example, in a 2-dimensional space, the distance between the point and the origin is always 1 according to the usual norms, but the distance between the point and the origin can be 2 under Manhattan distance, under Euclidean distance, or 1 under maximum distance.
Some commonly used metrics for hierarchical clustering are:
NamesFormula
Euclidean distance
Squared Euclidean distance
Manhattan distance
Maximum distance
Mahalanobis distancewhere S is the Covariance matrix

For text or other non-numeric data, metrics such as the Hamming distance or Levenshtein distance are often used.
A review of cluster analysis in health psychology research found that the most common distance measure in published studies in that research area is the Euclidean distance or the squared Euclidean distance.

Linkage criteria

The linkage criterion determines the distance between sets of observations as a function of the pairwise distances between observations.
Some commonly used linkage criteria between two sets of observations A and B are:
NamesFormula
Maximum or complete-linkage clustering
Minimum or single-linkage clustering
Unweighted average linkage clustering
Weighted average linkage clustering
Centroid linkage clustering, or UPGMCwhere and are the centroids of clusters s and t, respectively.
Minimum energy clustering

where d is the chosen metric. Other linkage criteria include:
Hierarchical clustering has the distinct advantage that any valid measure of distance can be used. In fact, the observations themselves are not required: all that is used is a matrix of distances.

Agglomerative clustering example

For example, suppose this data is to be clustered, and the Euclidean distance is the distance metric.
The hierarchical clustering dendrogram would be as such:
Cutting the tree at a given height will give a partitioning clustering at a selected precision. In this example, cutting after the second row of the dendrogram will yield clusters . Cutting after the third row will yield clusters , which is a coarser clustering, with a smaller number but larger clusters.
This method builds the hierarchy from the individual elements by progressively merging clusters. In our example, we have six elements and. The first step is to determine which elements to merge in a cluster. Usually, we want to take the two closest elements, according to the chosen distance.
Optionally, one can also construct a distance matrix at this stage, where the number in the i-th row j-th column is the distance between the i-th and j-th elements. Then, as clustering progresses, rows and columns are merged as the clusters are merged and the distances updated. This is a common way to implement this type of clustering, and has the benefit of caching distances between clusters. A simple agglomerative clustering algorithm is described in the single-linkage clustering page; it can easily be adapted to different types of linkage.
Suppose we have merged the two closest elements b and c, we now have the following clusters,,, and, and want to merge them further. To do that, we need to take the distance between and, and therefore define the distance between two clusters.
Usually the distance between two clusters and is one of the following:
In case of tied minimum distances, a pair is randomly chosen, thus being able to generate several structurally different dendrograms. Alternatively, all tied pairs may be joined at the same time, generating a unique dendrogram.
One can always decide to stop clustering when there is a sufficiently small number of clusters. Some linkages may also guarantee that agglomeration occurs at a greater distance between clusters than the previous agglomeration, and then one can stop clustering when the clusters are too far apart to be merged. However, this is not the case of, e.g., the centroid linkage where the so-called reversals may occur.

Divisive clustering

The basic principle of divisive clustering was published as the DIANA algorithm. Initially, all data is in the same cluster, and the largest cluster is split until every object is separate.
Because there exist ways of splitting each cluster, heuristics are needed. DIANA chooses the object with the maximum average dissimilarity and then moves all objects to this cluster that are more similar to the new cluster than to the remainder.

Software

Open source implementations