Hierarchical clustering

In hierarchical clustering, the two most similar clusters are combined and continue to combine until all objects are in the same cluster. Hierarchical clustering produces a tree called a dendrogram that shows the hierarchy of the clusters.

To show this concept, let's start by looking at the dataset called animals embedded in the R package called cluster:

> library(cluster) 
> data(animals) 
> dim(animals) 
[1] 20  6 
> head(animals) 
    war fly ver end gro hai 
ant   1   1   1   1   2   1 
bee   1   2   1   1   2   2 
cat   2   1   2   1   1   2 
cpl   1   1   1   1   1   2 
chi   2   1   2   2   2   2 
cow   2   1   2   1   2   2 
> colnames(animals) 
[1] "war" "fly" "ver" "end" "gro" "hai" 
> apply(animals,2, table) # simple overview 
  war fly ver end gro hai 
1  10  16   6  12   6  11 
2  10   4  14   6  11   9 

In total, ...

Get Hands-On Data Science with Anaconda now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.