Chapter 5
Similarity-based visualization
HAT-VIS draws a hypergraph by placing vertices according to how similar their memberships are, so that the distance in the picture carries meaning. This chapter develops the pipeline step by step: the weighted Jaccard similarity of incidence profiles, its max-product transitive closure, the embedding of the dissimilarities by classical multidimensional scaling or Sammon mapping, and the drawing of hyperedges as minimum spanning trees. It then introduces the membership-aware layout of hatvis, which keeps the similarity geometry while pushing non-members out of the hyperedges, and applies the pipeline to the house of quality of an autonomous electric car, the case study of the HAT-VIS paper.
5.1 Problem and idea
A force-directed layout places vertices so that the drawing looks balanced; the distance between two vertices has no direct meaning. For many questions, however, the distance is exactly what one wants to read: two customer requirements that are served by the same engineering solutions should appear close, two resources that are always used together should overlap, and a resource that links two otherwise separate groups should sit between them. HAT-VIS [1] achieves this by deriving a similarity between vertices from their incidence profiles and placing the vertices so that their planar distances approximate the dissimilarities (fig. 5.1). The layout is then a map of the similarity structure, and the hyperedges are drawn on top of it.
The approach has two consequences that this chapter addresses. Vertices with identical memberships become identical points (section 2.2.4), which is correct but needs care in the drawing. And a layout that is faithful to similarities can still place a non-member inside the outline of a hyperedge, because the non-member may resemble the members without belonging to the group; the membership-aware layout of section 5.2.5 reduces such intrusions without giving up the meaning of the distances.
5.2 Theory
5.2.1 Similarity of incidence profiles
A vertex is described by its row of the incidence matrix, scaled by the hyperedge weights: the profile . For a plain hypergraph the profile is the indicator vector of the hyperedges that contain ; for the house of quality below it is the vector of weighted relationship scores. HAT-VIS compares profiles with the weighted Jaccard (Ruzicka) similarity
|
| (5.1) |
which for 0/1 profiles reduces to Jaccard’s coefficient [72] , the number of shared hyperedges divided by the number of hyperedges of either vertex. The similarity is 1 for identical profiles and 0 for vertices without a common hyperedge. hatvis offers the alternatives that the literature uses most often: the Dice coefficient , the overlap coefficient (normalized by the smaller profile, so that a vertex whose hyperedges are a subset of another’s has similarity 1 with it), the cosine of the profiles, the asymmetric inclusion , the Hamming similarity of the 0/1 patterns, and the plain count of shared hyperedges. Applied to the dual hypergraph, the same measures compare hyperedges by their members.
5.2.2 Transitive closure
Jaccard similarity is local: two vertices that never share a hyperedge have similarity zero, however strongly they are linked through others. In the small example of section 1.6, and share no hyperedge, so , although is similar to () and to (). HAT-VIS replaces by its max-product transitive closure
|
| (5.2) |
the similarity of the strongest chain of pairwise similarities from to . In the example . Taking logarithms turns (5.2) into a shortest-path problem with edge lengths , so is computed by the Floyd–Warshall recursion [73] in time. The result is symmetric, never smaller than , keeps the unit diagonal, and is max-product transitive: for all . The classical alternative of fuzzy set theory is the max-min closure of Zadeh’s similarity relations [74], which makes an ultrametric and is therefore suited to hierarchical clustering rather than to embedding; it is available as transitive_closure(S, "max-min").
The closure changes the picture in a specific way. Without it, all pairs without a common hyperedge are equally dissimilar (distance 1) and the embedding has to place them at the same distance, which is impossible in two dimensions for more than three such vertices and produces a crowded center. With it, distances grow with the number and weakness of the links in between, and the layout spreads the vertices along the chains of the hypergraph.
5.2.3 Embedding the dissimilarities
The dissimilarity matrix (with zero diagonal) is embedded in the plane by classical multidimensional scaling [75]. With the matrix of squared dissimilarities and the centering matrix , the doubly centered matrix
|
| (5.3) |
is the Gram matrix of a configuration that reproduces exactly whenever is Euclidean. Its two largest eigenpairs give the coordinates ; negative eigenvalues, which occur for non-Euclidean dissimilarities, are discarded. Classical MDS is deterministic and fast, but it fits the large dissimilarities best and tends to compress the small ones, so groups of similar vertices may collapse.
Sammon mapping [76] weights each pair by the inverse of its dissimilarity and minimizes
|
| (5.4) |
where ; small dissimilarities are therefore preserved more faithfully, and local neighborhoods are easier to read. hatvis minimizes (5.4) with Sammon’s diagonal Newton step and step halving, starting from the classical MDS configuration; pairs with (equivalent vertices) are excluded from the sum and stay together.
5.2.4 Drawing on the similarity map
HAT-VIS draws every hyperedge as the minimum spanning tree of its members with respect to the dissimilarities of (5.1), i.e. along the strongest similarity links inside the group, colored per hyperedge and with a line width proportional to the hyperedge weight or to a hyperedge centrality; vertex sizes can show a vertex centrality. The trees use little ink and stay readable when many hyperedges overlap, which is typical of similarity maps, where the members of a hyperedge are by construction close together. An ego view draws only the hyperedges of one chosen vertex, and the seriated similarity matrix, with rows and columns in the barycentric order of section 3.2.2, complements the map with a view in which every pairwise value can be read. Any style of section 4.2.4 can be used instead of the trees.
Equivalent vertices are placed on the same point. HAT-VIS writes their labels together, which hatvis reproduces (“, ” in fig. 5.2); alternatively a small jitter separates them, or H.collapse_nodes() replaces each class by one vertex whose size shows the class size.
5.2.5 The membership-aware layout
A similarity layout is faithful, not legible: a vertex that resembles the members of a hyperedge without belonging to it may land inside the hull of that hyperedge. On the wire-harness space of section 3.4, classical MDS produces 290 intrusions in 60 of the 70 hyperedges (table 5.1). The membership-aware layout of hatvis combines the stress of the similarity embedding with a geometric constraint derived from the hyperedges. It alternates two steps (algorithm 5.1).
The first is one iteration of stress majorization (SMACOF) [77, 78] toward the dissimilarities: with the current configuration and , the Guttman transform
|
| (5.5) |
decreases the raw stress monotonically. The second is a projection: every hyperedge defines a disc with center , the centroid of its members, and radius with a small margin ; every non-member inside the disc is moved a fraction of the way toward its boundary along the ray from the center. The projection is the separation-constraint idea of constrained stress layouts [79] applied to the discs of the hyperedges. Neither step alone solves the problem: the majorization step pulls similar non-members back in, and the projection alone destroys the geometry. Alternating them, and keeping the iterate with the fewest intrusions counted on the actual padded hulls, yields a layout with nearly the stress of the similarity embedding and far fewer false enclosures. The fraction (strength, 0.25 by default) controls the trade-off.
5.2.6 Quality function deployment as a hypergraph
Quality function deployment (QFD) translates the voice of the customer into engineering specifications [80, 81]. Its central tool, the house of quality [82], is a matrix whose rows are customer requirements with importance ratings, whose columns are engineering specifications, and whose cells are relationship strengths on a 9/3/1 scale; a triangular roof records the correlations between specifications. Abonyi and Czvetkó [3] observed that this matrix is the incidence matrix of a hypergraph: every specification is a hyperedge that joins the requirements it affects, the incidence value is the relationship strength, and the importance of a requirement can be multiplied into its row. The HAT-VIS case study [1] uses exactly this construction, with
|
| (5.6) |
where is the relationship between requirement and specification and the importance of the requirement. The similarity map then shows which requirements are served by the same specifications, the dual map shows which specifications serve the same requirements (and are therefore candidates for integration or substitution), and centralities rank both. The optimization problems built on the same hypergraph, selecting a set of specifications under a budget and assigning specifications to requirements by network flow, are the subject of section 10.2.5.
In a nutshell: Similarity-based visualization (HAT-VIS)
- Profiles: weighted incidence rows ; similarity: weighted Jaccard (5.1) (Dice, overlap, cosine, inclusion, Hamming available).
- Max-product transitive closure (5.2): strongest chain, Floyd–Warshall, .
- Embedding of : classical MDS (5.3) (global, deterministic) or Sammon mapping (5.4) (local neighborhoods).
- Drawing: minimum spanning trees of the members along the strongest similarity links, widths by weight or centrality, ego view, seriated similarity matrix; equivalent vertices coincide.
- Membership-aware layout: SMACOF step plus disc projection of non-members, keep the iterate with the fewest intrusions; parameter strength.
- QFD: requirements as vertices, specifications as hyperedges, .
5.3 Using it in hatvis
vertex_similarity(H, measure="jaccard", weighted=True, transitive=False, closure="max-product", as_frame=False)
- measure
-
"jaccard", "dice", "overlap", "cosine", "inclusion", "hamming", "count".
- weighted
-
scale the incidence rows by the hyperedge weights (HAT-VIS).
- transitive, closure
-
apply the max-product or max-min closure.
- Related
-
edge_similarity(H) (the same on the dual), transitive_closure(S, method), dissimilarity(H), hypergraph_distance(H1, H2, kind).
layout_similarity(H, measure="jaccard", transitive=True, method="cmds", weighted=True, jitter=0.0)
- method
-
"cmds" (classical MDS) or "sammon".
- jitter
-
small random displacement that separates equivalent vertices.
- Related
-
layout_membership(H, init="similarity", n_iter=300, strength=0.25, margin=0.04, check_every=10); classical_mds(D), sammon(D); draw_hatvis(H, mode="mst", ego=None, width_by, size_by); plot_similarity_matrix(S, order); datasets.load_electric_car_qfd().
5.4 Examples
The pipeline step by step. On the five-vertex example the four steps of HAT-VIS are four lines.
S = hv.vertex_similarity(H) # weighted Jaccard ST = hv.transitive_closure(S, "max-product") # strongest chains Delta = 1 - ST Y = hv.layout.classical_mds(Delta) # 2-D configuration
Figure 5.2 shows the two similarity matrices and the drawing. The Jaccard similarity of and is 1 (equal memberships), that of and is (one shared hyperedge out of three), that of and is , and and have similarity 0. The transitive closure raises the last value to , the value reported in the HAT-VIS paper, and leaves all others unchanged, because they are already the strongest chains. Classical MDS places and on the same point , and symmetrically at , and at : the layout has the mirror symmetry of the hypergraph, which is invariant under exchanging with and with .
Open in ColabExample plot_14_hatvis_pipeline.py in the gallery
An autonomous electric car. The house of quality of the HAT-VIS case study relates eight customer requirements to eleven engineering specifications. The requirements are autonomous driving quality and reliability (CR1, importance 5), fast battery charging (CR2, 4), short travel time (CR3, 3), obstacle avoidance (CR4, 4), a user-friendly interface (CR5, 3), boot space (CR6, 2), a good braking system (CR7, 4), and an efficient safety system (CR8, 5). The specifications are LiDAR (ES1), GPS navigation (ES2), the battery management system (ES3), grid charging (ES4), sensors (ES5), algorithms (ES6), the classification of the vehicle (ES7), the number of seats (ES8), the type of brakes (ES9), airbags (ES10), and the supplementary restraint system (ES11). With the incidence (5.6), the requirements are the vertices and the specifications the hyperedges; the script ranks both with the linear node–edge eigenvector centrality of Tudisco and Higham [83], which is explained in section 6.2.5.
x, y = hv.node_edge_eigenvector(H, "linear") print("vertex centrality:\n", x.sort_values(ascending=False).round(4).head(4).to_string()) print("hyperedge centrality:\n", y.sort_values(ascending=False).round(4).head(4).to_string())
Autonomous driving quality (CR1, centrality 0.230) and the safety system (CR8, 0.206) are the most central requirements, followed at a distance by braking (CR7, 0.126) and obstacle avoidance (CR4, 0.125). Among the specifications, sensors (ES5) and algorithms (ES6) are tied at the top (0.158), followed by LiDAR (ES1, 0.134) and the vehicle classification (ES7, 0.114). The ranking agrees with the reading of the house of quality: the perception and decision stack serves the two most important requirements with the strongest relationships.
fig, axes = plt.subplots(1, 3, figsize=(18, 5.6)) draw_hatvis(H, ax=axes[0], width_by=y, size_by=x, title="requirements (vertices) and specifications") draw_hatvis(H, ax=axes[1], ego="CR4", width_by=y, size_by=x, title="ego view of CR4 (obstacle avoidance)") draw_hatvis(H.dual(), ax=axes[2], title="dual: specifications as vertices")
Figure 5.3 shows the three views. On the similarity map autonomous driving (CR1) and obstacle avoidance (CR4) form the tightest pair (transitive similarity 0.38, the largest in the matrix), because both rely on LiDAR, sensors, and algorithms. Charging (CR2), travel time (CR3), and boot space (CR6) form a second group on the opposite side, held together by the battery management system, the vehicle classification, and the number of seats, while the interface (CR5), the safety system (CR8), and braking (CR7) spread between the two groups: each shares some specifications with both. The ego view of obstacle avoidance (CR4) shows that it is served by exactly three specifications, LiDAR, sensors, and algorithms, all of which also serve CR1. In the dual map the airbags (ES10) and the supplementary restraint system (ES11) coincide: they relate to exactly the same requirements with the same strengths, so from the point of view of the house of quality they are one specification, a fact that the matrix shows only to a careful reader and the map shows at once.
Fewer intrusions. The last script compares classical MDS, Sammon mapping, and the membership-aware layout on the whole wire-harness space and on a fourteen-activity part of production line 1 (AGV loading, crimp positioning, hand-over, and two assembly activity types).
layouts = {"classical MDS": hv.layout_similarity(H, jitter=0.01, random_state=0), "Sammon mapping": hv.layout_similarity(H, method="sammon"), "membership-aware": hv.layout_membership(H, random_state=0)} quality = pd.DataFrame({name: hv.layout_quality(H, pos) for name, pos in layouts.items()}).T
| Data | Layout | Stress | Intrusions |
|
||
| whole space | classical MDS | 0.211 | 290 | 60 | ||
| Sammon mapping | 0.137 | 83 | 47 | |||
| membership-aware | 0.182 | 69 | 27 | |||
| line-1 part | classical MDS | 0.107 | 23 | 12 | ||
| Sammon mapping | 0.085 | 4 | 3 | |||
| membership-aware | 0.083 | 1 | 1 |
Table 5.1 shows the trade-off. On the whole space, classical MDS crowds the many resources that share the AGV and the sensors into a small region and produces 290 intrusions. Sammon mapping, which preserves small dissimilarities better, has the lowest stress and reduces the intrusions to 83. The membership-aware layout accepts a stress between the two and reduces the number of hyperedges with an intrusion from 47 to 27. On the line-1 part the membership-aware layout is better on both measures, with a single intrusion left (fig. 5.4). On the production example of table 4.1 it had the lowest stress and no intrusion at all. The projection does not create the geometry, which still comes from the similarities; it only resolves the conflicts that the similarity embedding leaves, and it is most effective when the hypergraph is not too dense for a planar drawing.
Open in ColabExample plot_16_membership_layout.py in the gallery
5.5 Further reading
The HAT-VIS paper [1] describes the MATLAB implementation and the electric-car case study; the QFD hypergraph is introduced in [3]. Torgerson [75] and Kruskal [60] are the classical references for metric and non-metric scaling, Sammon [76] for the mapping that bears his name, and de Leeuw and Mair [77] for the majorization algorithm; Gansner, Koren, and North [78] brought stress majorization to graph drawing and Dwyer, Koren, and Marriott [79] added separation constraints. Zadeh [74] introduced similarity relations and their transitive closures. Surana, Chen, and Rajapakse [19] and Felippe, Kirkley, and Battiston [84] compare whole hypergraphs rather than vertices, a question taken up in chapter 12.