In the previous chapters, we analyzed clustering algorithms, where the output is a single segmentation based either on a predefined number of clusters or the result of a parameter set and a precise underlying geometry. On the other hand, hierarchical clustering generates a sequence of clustering configurations that can be arranged in the structure of a tree. In particular, let's suppose that we have a dataset, X, containing n samples:
![](https://static.packt-cdn.com/products/9781789348279/graphics/assets/04851041-5aa5-40f4-871e-41cee0b1eb59.png)
An agglomerative approach starts by assigning each sample to a cluster, Ci, and proceeds by merging two clusters at each step until a single final cluster (corresponding to X) has been produced:
![](https://static.packt-cdn.com/products/9781789348279/graphics/assets/543602f0-e890-481e-9ebd-28453d15217b.png)
In the preceding example, the clusters Ci and Cj are merged into Ck; hence, we obtain n-1 clusters in the second step. The process continues until the two remaining clusters are merged into a single block containing the whole dataset...