Sub topic 12
Clustering the Matrix and Reading a Dendrogram
Assume you understand card-sorting sessions, similarity matrices, and basic percentages. This chapter focuses on turning pairwise grouping data into candidate card groups. Clustering is evidence for a structure, not an automatic decision about navigation.
From similarity to distance
A similarity matrix records how often participants grouped two cards together. A value of 1.00 means every participant paired them. A value of 0.25 means one quarter did.
Clustering algorithms usually work with distance rather than similarity. Convert the values with:
distance = 1 - similarityA pair with similarity 1.00 has distance 0. A pair with similarity 0.00 has distance 1. The diagonal remains zero after conversion because a card is identical to itself.
Hierarchical clustering
Hierarchical clustering builds a hierarchy of groups instead of producing only one answer. It begins with every card as its own group. It repeatedly joins the closest groups until all cards belong to one group.
The rule for measuring the distance between groups is called linkage. Average linkage uses the average distance between every card in one group and every card in the other group. It is often a useful starting point because it avoids relying only on the two closest cards.
import numpy as np
from scipy.cluster.hierarchy import linkage, fcluster
from scipy.spatial.distance import squareform
cards = ["Shipping rates", "Track order", "Returns", "Gift cards"]
similarity = np.array([
[1.00, 1.00, 0.67, 0.00],
[1.00, 1.00, 0.67, 0.00],
[0.67, 0.67, 1.00, 0.33],
[0.00, 0.00, 0.33, 1.00],
])
distance = 1 - similarity
condensed_distance = squareform(distance, checks=False)
linkage_matrix = linkage(condensed_distance, method="average")
# Cut the hierarchy where pairwise distance reaches 0.5.
labels = fcluster(linkage_matrix, t=0.5, criterion="distance")
for card, label in zip(cards, labels):
print(f"Cluster {label}: {card}")The linkage matrix stores each merge and its distance. The fcluster call cuts that hierarchy at a chosen threshold. A lower threshold creates smaller, tighter groups. A higher threshold creates fewer, broader groups.
| Choice | What it changes | Risk |
|---|---|---|
| Lower cut distance | More specific groups | Important relationships may be split |
| Higher cut distance | Broader groups | Unrelated cards may be combined |
| Average linkage | Uses all cross-group distances | Can hide a strong local relationship |
Reading a dendrogram
A dendrogram is a tree showing the order in which cards or groups were joined. The height of each merge represents distance. Low merges indicate strong similarity. High merges indicate weaker similarity.
To choose a cut, look for a noticeable vertical gap between merge heights. Then compare several possible cuts with the raw matrix. A visually neat cluster is weak evidence if its cards were rarely grouped together.
From clusters to structure
Treat clusters as candidate themes, not final menu labels. Review:
- Whether the cards in a cluster have a clear user-facing purpose.
- Whether one card belongs to several plausible groups.
- Whether participant-created category names explain the relationship.
- Whether the proposed groups support common tasks.
- Whether the result works at the level of navigation you need.
Try more than one linkage method or cut distance when the result is unstable. If small changes produce very different groups, report that uncertainty and test the competing structures with tree testing.
Exercise
Similarity between “Track order” and “Returns” is 0.67, while similarity between “Track order” and “Gift cards” is 0.00. Which card is more likely to join “Track order” early, and why?
Show answer
“Returns” is more likely to join early because its distance is 0.33, compared with a distance of 1.00 for “Gift cards.”