In
data mining and
statistics
Statistics (from German language, German: ''wikt:Statistik#German, Statistik'', "description of a State (polity), state, a country") is the discipline that concerns the collection, organization, analysis, interpretation, and presentation of ...
, hierarchical clustering (also called hierarchical cluster analysis or HCA) is a method of
cluster analysis
Cluster analysis or clustering is the task of grouping a set of objects in such a way that objects in the same group (called a cluster) are more similar (in some sense) to each other than to those in other groups (clusters). It is a main task of ...
that seeks to build a
hierarchy
A hierarchy (from Greek: , from , 'president of sacred rites') is an arrangement of items (objects, names, values, categories, etc.) that are represented as being "above", "below", or "at the same level as" one another. Hierarchy is an important ...
of clusters. Strategies for hierarchical clustering generally fall into two categories:
* Agglomerative: This is a "
bottom-up" approach: Each observation starts in its own cluster, and pairs of clusters are merged as one moves up the hierarchy.
* Divisive: This is a "
top-down
Top-down may refer to:
Arts and entertainment
* "Top Down", a 2007 song by Swizz Beatz
* "Top Down", a song by Lil Yachty from '' Lil Boat 3''
* "Top Down", a song by Fifth Harmony from '' Reflection'' Science
* Top-down reading, is a part of ...
" approach: All observations start in one cluster, and splits are performed recursively as one moves down the hierarchy.
In general, the merges and splits are determined in a
greedy manner. The results of hierarchical clustering are usually presented in a
dendrogram
A dendrogram is a diagram representing a tree. This diagrammatic representation is frequently used in different contexts:
* in hierarchical clustering, it illustrates the arrangement of the clusters produced by the corresponding analyses.
...
.
The standard algorithm for hierarchical agglomerative clustering (HAC) 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 (of complexity
) are known: SLINK
for
single-linkage and CLINK
for
complete-linkage clustering. With a
heap
Heap or HEAP may refer to:
Computing and mathematics
* Heap (data structure), a data structure commonly used to implement a priority queue
* Heap (mathematics), a generalization of a group
* Heap (programming) (or free store), an area of memory f ...
, the runtime of the general case can be reduced to
, an improvement on the aforementioned bound of
, 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 (except exhaustive search in
) 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.
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.
Cluster Linkage
In order to decide which clusters should be combined (for agglomerative), or where a cluster should be split (for divisive), a measure of dissimilarity between sets of observations is required. In most methods of hierarchical clustering, this is achieved by use of an appropriate
distance ''d'', such as the Euclidean distance, between ''single'' observations of the data set, and a linkage criterion, which specifies the dissimilarity of ''sets'' as a function of the pairwise distances of observations in the sets. The choice of metric as well as linkage can have a major impact on the result of the clustering, where the lower level metric determines which objects are most similar, whereas the linkage criterion influences the shape of the clusters. For example, complete-linkage tends to produce more spherical clusters than single-linkage.
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'' and a distance ''d'' are:
Some of these can only be recomputed recursively (WPGMA, WPGMC), for many a recursive computation with Lance-Williams-equations is more efficient, while for other (Mini-Max, Hausdorff, Medoid) the distances have to be computed with the slower full formula. Other linkage criteria include:
* The probability that candidate clusters spawn from the same distribution function (V-linkage).
* The product of in-degree and out-degree on a k-nearest-neighbour graph (graph degree linkage).
* The increment of some cluster descriptor (i.e., a quantity defined for measuring the quality of a cluster) after merging two clusters.
Agglomerative clustering example
For example, suppose this data is to be clustered, and the
Euclidean distance is the
distance metric.
The hierarchical clustering
dendrogram
A dendrogram is a diagram representing a tree. This diagrammatic representation is frequently used in different contexts:
* in hierarchical clustering, it illustrates the arrangement of the clusters produced by the corresponding analyses.
...
would be:
Cutting the tree at a given height will give a partitioning clustering at a selected precision. In this example, cutting after the second row (from the top) of the
dendrogram
A dendrogram is a diagram representing a tree. This diagrammatic representation is frequently used in different contexts:
* in hierarchical clustering, it illustrates the arrangement of the clusters produced by the corresponding analyses.
...
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 (see below).
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:
* The maximum distance between elements of each cluster (also called
complete-linkage clustering):
::
* The minimum distance between elements of each cluster (also called
single-linkage clustering):
::
* The mean distance between elements of each cluster (also called average linkage clustering, used e.g. in
UPGMA):
::
* The sum of all intra-cluster variance.
* The increase in variance for the cluster being merged (
Ward's method)
* The probability that candidate clusters spawn from the same distribution function (V-linkage).
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 (number criterion). 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 (distance criterion). However, this is not the case of, e.g., the centroid linkage where the so-called reversals (inversions, departures from ultrametricity) may occur.
Divisive clustering
The basic principle of divisive clustering was published as the DIANA (DIvisive ANAlysis Clustering) 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
*
ALGLIB implements several hierarchical clustering algorithms (single-link, complete-link, Ward) in C++ and C# with O(n²) memory and O(n³) run time.
*
ELKI includes multiple hierarchical clustering algorithms, various linkage strategies and also includes the efficient SLINK,
CLINK
and Anderberg algorithms, flexible cluster extraction from dendrograms and various other
cluster analysis
Cluster analysis or clustering is the task of grouping a set of objects in such a way that objects in the same group (called a cluster) are more similar (in some sense) to each other than to those in other groups (clusters). It is a main task of ...
algorithms.
*
Julia has an implementation inside the Clustering.jl package.
*
Octave
In music, an octave ( la, octavus: eighth) or perfect octave (sometimes called the diapason) is the interval between one musical pitch and another with double its frequency. The octave relationship is a natural phenomenon that has been refer ...
, the
GNU analog to
MATLAB implements hierarchical clustering in function "linkage".
*
Orange, a data mining software suite, includes hierarchical clustering with interactive dendrogram visualisation.
*
R has built-in functions and packages that provide functions for hierarchical clustering.
*
SciPy implements hierarchical clustering in Python, including the efficient SLINK algorithm.
*
scikit-learn also implements hierarchical clustering in Python.
*
Weka includes hierarchical cluster analysis.
Commercial implementations
*
MATLAB includes hierarchical cluster analysis.
*
SAS
SAS or Sas may refer to:
Arts, entertainment, and media
* ''SAS'' (novel series), a French book series by Gérard de Villiers
* ''Shimmer and Shine'', an American animated children's television series
* Southern All Stars, a Japanese rock ba ...
includes hierarchical cluster analysis in PROC CLUSTER.
*
Mathematica
Wolfram Mathematica is a software system with built-in libraries for several areas of technical computing that allow machine learning, statistics, symbolic computation, data manipulation, network analysis, time series analysis, NLP, optimizat ...
includes a Hierarchical Clustering Package.
*
NCSS includes hierarchical cluster analysis.
*
SPSS includes hierarchical cluster analysis.
*
Qlucore Omics Explorer includes hierarchical cluster analysis.
*
Stata
Stata (, , alternatively , occasionally stylized as STATA) is a general-purpose statistical software package developed by StataCorp for data manipulation, visualization, statistics, and automated reporting. It is used by researchers in many fie ...
includes hierarchical cluster analysis.
*
CrimeStat includes a nearest neighbor hierarchical cluster algorithm with a graphical output for a Geographic Information System.
See also
*
Binary space partitioning
*
Bounding volume hierarchy
*
Brown clustering
*
Cladistics
*
Cluster analysis
Cluster analysis or clustering is the task of grouping a set of objects in such a way that objects in the same group (called a cluster) are more similar (in some sense) to each other than to those in other groups (clusters). It is a main task of ...
*
Computational phylogenetics
*
CURE data clustering algorithm
*
Dasgupta's objective In the study of hierarchical clustering, Dasgupta's objective is a measure of the quality of a clustering, defined from a similarity measure on the elements to be clustered. It is named after Sanjoy Dasgupta, who formulated it in 2016. Its key prope ...
*
Dendrogram
A dendrogram is a diagram representing a tree. This diagrammatic representation is frequently used in different contexts:
* in hierarchical clustering, it illustrates the arrangement of the clusters produced by the corresponding analyses.
...
*
Determining the number of clusters in a data set
*
Hierarchical clustering of networks Hierarchical clustering is one method for finding community structures in a network. The technique arranges the network into a hierarchy of groups according to a specified weight function. The data can then be represented in a tree structure known ...
*
Locality-sensitive hashing
*
Nearest neighbor search
*
Nearest-neighbor chain algorithm
*
Numerical taxonomy
*
OPTICS algorithm
*
Statistical distance
In statistics, probability theory, and information theory, a statistical distance quantifies the distance between two statistical objects, which can be two random variables, or two probability distributions or samples, or the distance can be be ...
*
Persistent homology
References
Further reading
*
*
{{DEFAULTSORT:Hierarchical Clustering
Network analysis
Cluster analysis algorithms