Chapter 6
Visual assessment and the quality of maps
Before clustering it is worth asking whether the data contain clusters at all, and after mapping, how faithful the map is. This chapter presents the VAT image, which reorders a dissimilarity matrix along the minimal spanning tree so that clusters appear as dark blocks, and its improved version iVAT. It then defines the measures used in the rest of the book to judge maps: distance-based stresses and the residual variance, trustworthiness and continuity, the co-ranking matrix with the , , and LCMC curves, and the topographic error and product.
6.1 Problem and idea
A dissimilarity matrix shown as a gray-scale image in an arbitrary order of the samples is noise. Ordered so that similar samples are adjacent, it shows clusters as dark squares on the diagonal. Bezdek and Hathaway [66] obtained such an order from Prim’s algorithm: start at an end of the largest dissimilarity and always append the sample closest to the samples already ordered. Because Prim’s algorithm builds the minimal spanning tree, a cluster—a subtree linked to the rest by a long edge—is visited completely before the algorithm jumps to the next one.
Judging a map is a separate question with two sides (fig. 6.1). A map should not create false neighborhoods: samples that are close in the display but not in the data mislead the viewer, and the map is then not trustworthy. It also should not tear true neighborhoods apart: samples close in the data should stay close, or the map is not continuous. No two-dimensional map of genuinely higher-dimensional data can achieve both perfectly; different methods choose different compromises, and both sides have to be measured.
6.2 Theory
6.2.1 VAT and iVAT
Given a dissimilarity matrix , VAT [66] computes the order of algorithm 6.1 and displays as an image. Since the order is that of Prim’s algorithm, single-linkage clusters appear as contiguous diagonal blocks. For clusters that are elongated or connected by chains, the blocks are faint: the dissimilarities within a long cluster are large at its two ends. iVAT [67] replaces every dissimilarity by the minimax path distance, the largest edge on the MST path between the two samples. Within a cluster all such paths use only short edges, between clusters they must use a long one, so the blocks become uniform and crisp. In VAT order the transformed matrix can be computed row by row in time: the new row of the -th sample is the elementwise maximum of its attaching edge and the row of the sample it attaches to.
6.2.2 Distance preservation
Let be the dissimilarities in the input space (Euclidean or geodesic) and the distances in the map. Three measures summarize how well distances are kept:
Sammon’s stress [68] divides each error by the input dissimilarity and therefore emphasizes small distances; the normalized metric stress weighs all errors equally and is dominated by large distances; the residual variance [6] uses the linear correlation of all pairs and is invariant to a rescaling of the map. When the purpose of a map is to unfold a manifold, the input dissimilarities should be geodesic distances: Euclidean distances penalize exactly the unrolling that the map is supposed to perform.
6.2.3 Neighborhood preservation: trustworthiness and continuity
Let be the rank of sample in the ordering of all samples by their dissimilarity from in the input space (, the nearest neighbor has rank 1), and the same rank in the map. For a neighborhood size , let be the samples among the nearest neighbors of in the map but not in the input space, and the samples among the nearest in the input space but not in the map. Venna and Kaski [69] define
Trustworthiness penalizes false neighbors in the map by how far away they really are; continuity penalizes missing neighbors by how far away the map puts them. Both lie in (one is perfect, random maps score about 0.5) and are computed for a range of : small tests local, large global structure.
6.2.4 The co-ranking framework
Lee and Verleysen [20] unified the rank-based measures with the co-ranking matrix , whose entry counts the pairs with and . A perfect map has a diagonal ; entries below the diagonal are intrusions (samples ranked closer in the map than in the data), entries above are extrusions. Trustworthiness and continuity are weighted sums of the intrusions and extrusions in the upper-left block. The average agreement of the -ary neighborhoods,
|
| (6.6) |
is the fraction of the nearest neighbors that are preserved. Because a random map already preserves a fraction , the rescaled curve
|
| (6.7) |
is zero for a random map and one for a perfect one, and the local continuity meta-criterion of Chen and Buja [70] subtracts the same baseline without rescaling. The area under with a logarithmic axis,
|
| (6.8) |
summarizes a map by one number that weighs small neighborhoods more [21]; it is the most common single criterion in recent comparisons of embeddings.
6.2.5 Map topology
For maps with a fixed or learned graph of nodes—self-organizing maps, TRNMap—two further measures check the graph itself. The topographic error [71] is the fraction of samples whose nearest and second nearest nodes are not adjacent in the map graph. The topographic product of Bauer and Pawelzik [72] compares, for every node, the order of its neighbors in the input space with their order in the map; values near zero indicate that the dimension of the map fits the data, negative values a map that is too small and folded, positive values one that is too large.
In a nutshell: Quality of a map
- VAT and iVAT reveal cluster tendency from any dissimilarity; iVAT is clearer for chained and elongated clusters.
- Sammon stress, metric stress, and residual variance measure distance preservation; use geodesic input distances for manifolds.
- Trustworthiness (false neighbors) and continuity (torn neighborhoods) measure neighborhood preservation as a function of .
- The co-ranking matrix yields , , LCMC, and the AUC summary.
6.3 Using it in graphclust
graphclust.vat, graphclust.metrics
vat(D) and ivat(D) return the image and the order. sammon_stress, mds_stress, residual_variance, trustworthiness_continuity(X_high, Y, k) (k may be a list), coranking_matrix, qnx_curve, rnx_curve, lcmc_curve, auc_rnx, mapping_quality (all measures in a dictionary): the first argument is a data matrix or, with precomputed=True, a dissimilarity matrix such as geodesic distances. topographic_error(X, nodes, map_adjacency), topographic_product(nodes, positions).
The co-ranking matrix is computed once and reused for all curves:
Q = metrics.coranking_matrix(X, Y) T[name], C[name] = metrics.trustworthiness_continuity(X, Y, ks, Q=Q) R[name] = metrics.rnx_curve(Q=Q) print(name, {k: round(v, 3) for k, v in metrics.mapping_quality(X, Y, k=(10,)).items()})
6.4 Examples
6.4.1 VAT and iVAT
Figure 6.2 shows VAT and iVAT images of the ChainLink and Curves data. For the four arcs of the Curves data, the VAT image is dominated by gradients within the elongated clusters, whereas the iVAT image shows four dark blocks. ChainLink shows the limits of both images: VAT has a faint block structure, and iVAT shows only two blocks, the lower group and the chained groups together. Minimax path distances are single-linkage distances, so they cannot see through the chain either; the volume criterion of chapter 4 or a density correction is needed for that.
6.4.2 Measuring maps of the swiss roll
Figure 6.3 evaluates three maps of the swiss roll. The co-ranking matrix of PCA has many intrusions below the diagonal: PCA projects the roll onto a plane and puts samples of different windings on top of each other. Its trustworthiness is the lowest of the three, while its continuity is high, since a projection never tears neighborhoods. Sammon’s mapping improves trustworthiness slightly. Isomap, which uses geodesic distances, unrolls the sheet and reaches values close to one for both measures and the highest curve. Its Sammon stress computed against Euclidean distances is nevertheless large (4.2 versus 0.06 for Sammon’s mapping), which illustrates why distance measures must use geodesic distances when unfolding is the goal.
Open in ColabExample plot_02_quality_measures.py in the gallery
6.5 Further reading
Bezdek and Hathaway [66] and Havens and Bezdek [67] describe VAT and iVAT. Trustworthiness and continuity are introduced by Venna and Kaski [69]; Venna et al. [73] give them an information retrieval interpretation as precision and recall of neighbors. The co-ranking framework is developed by Lee and Verleysen [20], and the AUC of by Lee, Peluffo-Ordóñez, and Verleysen [21].