Similarity matrix
A similarity matrix is a matrix whose entries quantify pairwise similarity between objects, items, data points, or their representations.
Data Without Labels
An affinity matrix is a matrix whose entries quantify pairwise similarities or affinities between data points.
- How it is used
- Supports spectral clustering by encoding pairwise affinity for graph-based connectivity analysis.
- How deep it goes
- Defines similarity values and links them to spectral clustering, but stops short of detailing matrix construction algorithms.
- Examples
- Uses weighted graph diagrams, adjacency-matrix figures, complex cluster shapes, and an exercise deriving graph matrices.
- What you can do after
- Build an affinity representation from graph-based similarity weights and relate it to spectral clustering inputs.
Natural Language Processing in Action, Second Edition
A similarity matrix is a square matrix whose entries quantify pairwise similarity between objects.
- How it is used
- Computes pairwise relationships among sentence embeddings and supplies weights for graph-based connections.
- How deep it goes
- Defines dimensions, normalization, dot-product computation, symmetry, and graph conversion without developing matrix internals.
- Examples
- Uses chapter sentences, 300-dimensional embeddings, NumPy arrays, and a thresholded NetworkX graph.
- What you can do after
- Apply it via NumPy to calculate pairwise sentence similarity and derive weighted graph edges.
Read how Natural Language Processing in Action, Second Edition explains similarity matrix →
Graph Neural Networks in Action
A similarity matrix is a matrix whose entries quantify the similarity between pairs of items or representations.
- How it is used
- Builds product bundles by ranking items whose learned node embeddings are most similar.
- How deep it goes
- Explains matrix construction and nearest-item ranking, but defers the underlying cosine-similarity mathematics.
- Examples
- Uses Amazon product nodes and a Marceline vinyl figure to demonstrate six-item bundle generation.
- What you can do after
- Apply it via scikit-learn to rank products nearest to a chosen embedding.
Read how Graph Neural Networks in Action explains similarity matrix →
Related concepts
- spectral clusteringused by · Spectral clustering is a clustering method that partitions data using eigenvectors of a graph-based affinity representation rather than only geometric location.
- cosine similarityuses · Cosine similarity measures the directional alignment of two nonzero vectors as the cosine of the angle between them, equivalently their dot product divided by the product of their magnitudes.
- user-item interaction matrixused by · A user-item interaction matrix is a matrix whose rows represent users, columns represent items, and entries encode their interactions, preferences, or ratings.
- adjacency matrixalternative to · An adjacency matrix is a square matrix whose rows and columns represent graph vertices and whose entries indicate edges or encode edge weights between vertex pairs.
- embeddingproduced by · A numerical vector representation of an item or input that encodes features or relationships useful for computational tasks.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


