Concepts / Similarity Measures

Similarity Measures

Spectral clustering begins by representing relationships between data points as a weighted similarity graph.

  • Programming

From Points to Relationships

Many clustering problems become easier to describe when we focus on relationships rather than treating data points as isolated objects. Spectral clustering begins by representing those relationships as a weighted similarity graph. This representation turns a collection of data points into a structure whose connections can be examined when forming groups.

The central idea is simple: data points become vertices, relationships become edges, and the strength of each relationship becomes an edge weight.

What do you think happens?

Suppose two data points receive a high similarity value. What should that tell you about their edge in the similarity graph?

  • The edge represents a strong similarity
  • The edge represents a weak similarity
  • The two points must belong to different groups
Reveal answer

Answer: The edge represents a strong similarity

The edge weight carries the meaningful information in the graph. A high-weight edge indicates strong similarity according to the chosen similarity function.

Reading a Similarity Graph

A similarity graph has three parts to interpret. Each vertex represents one data point. An edge represents the connection between two data points. The edge weight represents the pairwise similarity between the corresponding points. In this setting, the graph records not only which points are related, but also how strong each relationship is.

connected byconnected byhasData point AvertexSimilarityedge with weightSimilarity valuestrength of relationshipData point Bvertex
What do vertices, edges, and edge weights represent in a similarity graph?

Turning Distance into Similarity

A similarity measure is the calculation used to assign a numerical relationship value to two data points. One possible approach uses a distance function and a parameter named sigma. The distance between the two points is supplied to the similarity calculation, while sigma controls part of that calculation. The resulting value is used as the edge weight between the corresponding vertices.

Graph elementWhat it representsHow to interpret it
VertexA data pointOne item in the data set
EdgeA relationship between two data pointsThe pairwise connection being evaluated
Edge weightThe numerical similarity between two data pointsHigher weight means stronger similarity; lower weight means weaker similarity

When interpreting a proposed clustering, inspect the weights rather than relying only on the group labels. The weights explain whether the proposed groups are supported by strong internal relationships and weak relationships across their boundaries.

Comparing Candidate Groups

Consider four data points represented by vertices A, B, C, and D. The following illustrative weights describe strong relationships between A and B, and between C and D. The weights connecting a point from the first pair to a point from the second pair are lower. This creates a natural candidate partition: one group containing A and B, and another containing C and D.

Evaluating a Two-Group Partition

Use the illustrative similarity weights to decide whether the partition {A, B} and {C, D} matches the spectral clustering objective.

Inspect the first group: The edge between A and B has a high weight, so the two points have a strong internal relationship.

Inspect the second group: The edge between C and D also has a high weight, so this group has a strong internal relationship.

Inspect cross-group edges: The edges from A or B to C or D have lower weights, so the relationships across the proposed boundary are weaker.

Compare both properties: The partition combines high within-group similarity with low between-group similarity, rather than optimizing only one of those properties.

The partition {A, B} and {C, D} is a good match for the stated spectral clustering objective.

high weighthigh weightlow weightlow weightlow weightlow weightAdata pointCdata pointBdata pointDdata point
How can a graph show that points within the same group are strongly connected while points in different groups are only weakly connected?

The Spectral Clustering Goal

The spectral clustering problem is to divide the vertices into groups whose internal connections are strong and whose connections across groups are weak. The partition does not require the graph to lose its original connections. Instead, each vertex receives a group label, and the existing edge weights are evaluated against those labels.

representevaluateevaluatecombine withcombine withWeighted similaritygraphvertices, edges, weightsGroup labelsassigned to verticesStrong internalconnectionswithin groupsPreferred partitionboth properties togetherWeak cross-groupconnectionsbetween groups
How does spectral clustering use a similarity graph to divide data points into groups with strong internal connections and weak connections between groups?

Mistakes in Graph Interpretation

  • Treating a vertex as a relationship

    A vertex represents one data point. The relationship between two data points is represented by an edge and its weight.

    Fix: Identify the data point at each vertex, then inspect the connecting edge and its weight.

  • Ignoring edge weights

    The meaningful information is carried by the weights, especially when every pair of points is connected.

    Fix: Compare the strengths of within-group and between-group edges.

  • Optimizing only within-group similarity

    The objective also requires weak connections across group boundaries.

    Fix: Evaluate high within-group similarity and low between-group similarity together.

  • Assuming clustering removes the original edges

    The partition assigns group labels and evaluates the existing edge weights; it does not require the graph to lose its original connections.

    Fix: Think of clustering as labeling vertices while assessing how well the existing weights support those labels.

Practice with a Partition

MEDIUM

A similarity graph has two proposed partitions. Partition X places pairs with high-weight edges inside groups, but also places several high-weight edges across group boundaries. Partition Y has slightly less internal similarity in one group, but its between-group edges are consistently weak. Which partition better matches the spectral clustering objective, and what two properties should you mention in your explanation?

Hints
  • Inspect both within-group and between-group relationships.
  • The objective combines strong internal connections with weak cross-group connections.
  • Do not decide from within-group weights alone.

A complete explanation should say whether each candidate has strong within-group relationships and weak between-group relationships. The preferred partition is the one that better combines both properties.

Key Takeaways

  1. A similarity graph represents each data point as a vertex and each pairwise relationship as an edge.
  2. The edge weight is the numerical similarity between two data points; high weight means strong similarity and low weight means weaker similarity.
  3. A distance function and a parameter such as sigma can be used as part of a similarity calculation.
  4. Spectral clustering assigns group labels while evaluating the existing edge weights.
  5. The desired partition has strong within-group relationships and weak between-group relationships.

Key Takeaways

  • Similarity graphs convert relationships among data points into a weighted graph.
  • Vertices represent data points, edges represent pairwise connections, and edge weights represent similarity strength.
  • Because every pair may be connected, edge weights—not merely edge existence—carry the important signal.
  • Spectral clustering seeks a partition with strong internal connections and weak connections across groups.
  • A correct interpretation evaluates within-group and between-group relationships together.