liveBook · Manning

Dendrogram

As explained in Data Without Labels

A dendrogram is a tree diagram that represents the nested grouping and merging of observations in hierarchical clustering.

A dendrogram is a tree diagram showing how observations are iteratively grouped or merged by connectivity. Its branches expose nested clusters, with leaves representing terminal observations or groups. section 2.4

In hierarchical clustering, merge height represents the distance between clusters. Clusters joined at similar heights are more closely related than clusters joined farther apart. section 2.4.3

Use a dendrogram to choose a practical cluster count:

  • Draw a horizontal cut across the dendrogram. section 2.4.3
  • Count the vertical branches intersected by the cut; that count is the number of clusters. section 2.4.3
  • Prefer a cut spanning the largest distance between successive merge heights, while checking that the resulting groups remain interpretable. section 2.4.3 section 2.4.4

Python workflow

Standardize the feature matrix, compute linkage with average, Ward, or complete methods, and plot the dendrogram with matplotlib. A truncated view of the last 10 merges can make the cut easier to inspect. Apply the selected distance with fcluster, count the resulting labels, and plot the groups. Different distance thresholds produce different cluster counts, so test several values. section 2.4.5

Figure 2.19 Dendrogram to identify the optimum number of clusters. The distance between X and Y is more than between A and B and between P and Q; hence, we choose that as the cut to create clusters and the number of clusters chosen is five. The x-axis represents the clusters, while the y-axis represents the distance (dissimilarity) between two clusters.
figure

Use the dendrogram figure to compare candidate horizontal cuts and relate merge heights to dissimilarity. section 2.4.3

How Data Without Labels covers it

How deep it goes
Defines branches, leaves, and merge heights, then gives a cutting procedure; it stops short of automatic optimum selection.
Examples
Uses candidate cuts, merge-height comparisons, Python linkage workflows, truncated plots, and scatterplots of resulting clusters.
What it assumes
Assumes feature data and distance-based similarity, while explaining hierarchical grouping, merge height, leaves, and horizontal cuts.
What you can do after
Apply it via SciPy and matplotlib to inspect hierarchical merges, select a distance threshold, and visualize resulting clusters.
How it connects
Connects hierarchical clustering with k-means clustering, linkage methods, distance metrics, and cluster segmentation.

Also explained in

Compare how 3 books explain dendrogram →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Without Labels. The section links point to the parts of the book it draws on.