As listed above, clustering algorithms can be categorized based on their cluster model. The following overview will only list the most prominent examples of clustering algorithms, as there are possibly over 100 published clustering algorithms. Not all provide models for their clusters and can thus not easily be categorized. An overview of algorithms explained in Wikipedia can be found in the
list of statistics algorithms. There is no objectively "correct" clustering algorithm, but as it was noted, "clustering is in the eye of the beholder." The most appropriate clustering algorithm for a particular problem often needs to be chosen experimentally, unless there is a mathematical reason to prefer one cluster model over another. An algorithm that is designed for one kind of model will generally fail on a data set that contains a radically different kind of model.
Connectivity-based clustering (hierarchical clustering) Connectivity-based clustering, also known as
hierarchical clustering, is based on the idea that objects are more related to nearby objects than to those farther away. These algorithms form clusters by connecting objects based on their distance. A cluster can be understood in terms of the maximum distance required to connect its elements. At different distance thresholds, different cluster groupings appear. These groupings can be visualized using a
dendrogram, a tree-like diagram that shows how clusters merge as the distance increases. This explains the term "
hierarchical clustering": instead of producing a single partition of the data set, the algorithm builds a hierarchy of clusters that merge at different distances. In a dendrogram, the y-axis shows the distance at which clusters merge, while the x-axis arranges objects so that clusters appear as continuous branches. Connectivity-based clustering is a family of methods that differ in how distances between clusters are computed. In addition to choosing a
distance function, the user must also select a
linkage criterion, which determines how the distance between clusters is calculated. Common linkage criteria include
single-linkage clustering (minimum distance between points),
complete linkage clustering (maximum distance), and
UPGMA or
WPGMA (average linkage based on mean distances). Hierarchical clustering can be either agglomerative (starting with individual elements and merging them) or divisive (starting with the full data set and splitting it). In agglomerative hierarchical clustering, the algorithm typically proceeds as follows: • Start with each data point as its own cluster. • Identify the two closest clusters based on a chosen distance measure. • Merge them into a single cluster. • Recalculate distances between the new cluster and the remaining clusters using the selected linkage criterion. • Repeat until all data points are merged into a single cluster. This process produces a full hierarchy of possible clusterings rather than a single final result. A specific clustering can be obtained by selecting a cut level in the dendrogram, which determines how many clusters are formed. These methods do not produce a unique partitioning of the data set, but rather a hierarchy from which the user must choose appropriate clusters. They are also sensitive to outliers, which may appear as separate clusters or cause other clusters to merge. This effect, especially in
single-linkage clustering, is known as the "chaining phenomenon". In the general case, the complexity is \mathcal{O}(n^3) for agglomerative clustering and \mathcal{O}(2^{n-1}) for
divisive clustering, which makes them computationally expensive for large data sets. For some special cases, more efficient methods (with complexity \mathcal{O}(n^2)) are known, such as SLINK for single-linkage and CLINK for complete-linkage clustering. File:SLINK-Gaussian-data.svg|Single-linkage on Gaussian data. At 35 clusters, the biggest cluster starts fragmenting into smaller parts, while before it was still connected to the second largest due to the single-link effect. File:SLINK-density-data.svg|Single-linkage on density-based clusters. 20 clusters extracted, most of which contain single elements, since linkage clustering does not have a notion of "noise".
Centroid-based clustering In centroid-based clustering, each cluster is represented by a central vector, which is not necessarily a member of the data set. When the number of clusters is fixed to
k,
k-means clustering gives a formal definition as an optimization problem: find the
k cluster centers and assign the objects to the nearest cluster center, such that the squared distances from the cluster are minimized. The optimization problem itself is known to be
NP-hard, and thus the common approach is to search only for approximate solutions. A particularly well-known approximate method is
Lloyd's algorithm, often just referred to as "
k-means algorithm" (although
another algorithm introduced this name). It does however only find a
local optimum, and is commonly run multiple times with different random initializations. Variations of
k-means often include such optimizations as choosing the best of multiple runs, but also restricting the centroids to members of the data set (
k-medoids), choosing
medians (
k-medians clustering), choosing the initial centers less randomly (
k-means++) or allowing a fuzzy cluster assignment (
fuzzy c-means). Most
k-means-type algorithms require the
number of clusters –
k – to be specified in advance, which is considered to be one of the biggest drawbacks of these algorithms. Furthermore, the algorithms prefer clusters of approximately similar size, as they will always assign an object to the nearest centroid; often yielding improperly cut borders of clusters. This happens primarily because the algorithm optimizes cluster centers, not cluster borders. Steps involved in the centroid-based clustering algorithm are: • Choose,
k distinct clusters at random. These are the initial centroids to be improved upon. • Suppose a set of observations, . Assign each observation to the centroid to which it has the smallest squared
Euclidean distance. This results in
k distinct groups, each containing unique observations. • Recalculate centroids (see
k-means clustering). • Exit
iff the new centroids are equivalent to the previous iteration's centroids. Else, repeat the algorithm, the centroids have yet to converge. K-means has a number of interesting theoretical properties. First, it partitions the data space into a structure known as a
Voronoi diagram. Second, it is conceptually close to nearest neighbor classification, and as such is popular in
machine learning. Third, it can be seen as a variation of model-based clustering, and Lloyd's algorithm as a variation of the
Expectation-maximization algorithm for this model discussed below. File:KMeans-Gaussian-data.svg|
k-means separates data into Voronoi cells, which assumes equal-sized clusters (not adequate here). File:KMeans-density-data.svg|
k-means cannot represent density-based clusters. The following pseudocode describes the standard iterative refinement form of
k-means. The algorithm alternates between an
assignment step, which labels each point by its nearest centroid, and an
update step, which recomputes each centroid as the mean of its assigned points. Convergence is guaranteed in a finite number of iterations, though the result may be a
local optimum.
input: dataset \mathbf{x}_1,...,\mathbf{x}_P, initializations for centroids \mathbf{c}_1,...,\mathbf{c}_K, maximum number of iterations J for \,\,j = 1,\ldots,J # Cluster assignments for \,\,p = 1,\ldots,P a_p =\underset{k=1,\ldots,K}{\mbox{argmin}}\,\,\left\Vert \mathbf{c}_{k}-\mathbf{x}_{p}\right\Vert _{2} # Update centroid locations for \,\,k = 1,\ldots,K \text{denote } S_k \text{ the index set of points } X_p\text{ currently assigned to the }k_{th}\text{ cluster} \text{update }c_k\text{ via }c_k=\frac{1}{\left|S_{k}\right|}\underset{p\in S_{k}}{\sum}\mathbf{x}_{p} # Update cluster assignments using final for \,\,p = 1,\ldots,P a_p =\underset{k=1,\ldots,K}{\mbox{argmin}}\,\,\left\Vert \mathbf{c}_{k}-\mathbf{x}_{p}\right\Vert _{2}
output: optimal centroids and assignments density-based clustering method is
DBSCAN. In contrast to many newer methods, it features a well-defined cluster model called "density-reachability". Similar to linkage-based clustering, it is based on connecting points within certain distance thresholds. However, it only connects points that satisfy a density criterion, in the original variant defined as a minimum number of other objects within this radius. A cluster consists of all density-connected objects (which can form a cluster of an arbitrary shape, in contrast to many other methods) plus all objects that are within these objects' range. Another interesting property of DBSCAN is that its complexity is fairly low – it requires a linear number of range queries on the database – and that it will discover essentially the same results (it is
deterministic for core and noise points, but not for border points) in each run, therefore there is no need to run it multiple times.
OPTICS is a generalization of DBSCAN that removes the need to choose an appropriate value for the range parameter \varepsilon, and produces a hierarchical result related to that of
linkage clustering. DeLi-Clu, Density-Link-Clustering combines ideas from
single-linkage clustering and OPTICS, eliminating the \varepsilon parameter entirely and offering performance improvements over OPTICS by using an
R-tree index.
HDBSCAN extends DBSCAN by converting it into a hierarchical clustering algorithm, and then using a technique to extract a flat clustering based in the stability of clusters. The key drawback of DBSCAN and
OPTICS is that they expect some kind of density drop to detect cluster borders. On data sets with, for example, overlapping Gaussian distributions – a common use case in artificial data – the cluster borders produced by these algorithms will often look arbitrary, because the cluster density decreases continuously. On a data set consisting of mixtures of Gaussians, these algorithms are nearly always outperformed by methods such as
EM clustering that are able to precisely model this kind of data.
Mean-shift is a clustering approach where each object is moved to the densest area in its vicinity, based on
kernel density estimation. Eventually, objects converge to local maxima of density. Similar to k-means clustering, these "density attractors" can serve as representatives for the data set, but mean-shift can detect arbitrary-shaped clusters similar to DBSCAN. Due to the expensive iterative procedure and density estimation, mean-shift is usually slower than DBSCAN or k-Means. Besides that, the applicability of the mean-shift algorithm to multidimensional data is hindered by the unsmooth behaviour of the kernel density estimate, which results in over-fragmentation of cluster tails. In this technique, we create a grid structure, and the comparison is performed on grids (also known as cells). The grid-based technique is fast and has low computational complexity. There are two types of grid-based clustering methods: STING and CLIQUE. Steps involved in the grid-based clustering
algorithm are: • Divide data space into a finite number of cells. • Randomly select a cell ‘c’, where c should not be traversed beforehand. • Calculate the density of ‘c’ • If the density of ‘c’ greater than threshold density • Mark cell ‘c’ as a new cluster • Calculate the density of all the neighbors of ‘c’ • If the density of a neighboring cell is greater than threshold density then, add the cell in the cluster and repeat steps 4.2 and 4.3 till there is no neighbor with a density greater than threshold density. • Repeat steps 2, 3, and 4 till all the cells are traversed. • Stop.
Big data With the increasing need to process
Big data, the willingness to trade semantic meaning of the generated clusters for performance becomes more relevant. Therefore, efforts have been put into improving the performance of existing algorithms. Among them are
CLARANS, and
BIRCH. This led to the development of pre-clustering methods such as
canopy clustering, which can process huge data sets efficiently, but the resulting "clusters" are merely a rough pre-partitioning of the data set to then analyze the partitions with existing slower methods such as
k-means clustering.
Subspace clustering For
high-dimensional data, many methods fail due to the
curse of dimensionality, which renders particular distance functions problematic in high-dimensional spaces. This led to
clustering algorithms for high-dimensional data that focus on
subspace clustering (where only some attributes are used, and cluster models include the relevant attributes for the cluster) and
correlation clustering that also looks for arbitrary rotated ("correlated") subspace clusters that can be modeled by giving a
correlation of their attributes. Examples for such clustering algorithms are CLIQUE and
SUBCLU. Ideas from density-based clustering methods (in particular the DBSCAN/OPTICS family of algorithms) have been adapted to subspace clustering (HiSC, hierarchical subspace clustering and DiSH) and correlation clustering (HiCO, hierarchical correlation clustering, 4C using "correlation connectivity" and ERiC exploring hierarchical density-based correlation clusters). Several different clustering systems based on
mutual information have been proposed. One is Marina Meilă's
variation of information metric; another provides hierarchical clustering. Using genetic algorithms, a wide range of different fit-functions can be optimized, including mutual information. Also
belief propagation, a recent development in
computer science and
statistical physics, has led to the creation of new types of clustering algorithms. == Evaluation and assessment ==