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 →
Also covered in
- AI Recommender SystemsIn early access (MEAP)
- Build a Text-to-Image Generator (from Scratch)
What to know first
- embeddingAn embedding is a numerical vector representation of an item in a feature space, encoding selected properties or relationships for computational tasks such as comparison or retrieval.
Related concepts
- spectral clusteringused by · Spectral clustering is a clustering method that uses eigenvectors of a graph-based representation of data to identify groups, including groups with complex shapes.
- cosine similarityuses · Cosine similarity measures the directional alignment of two nonzero vectors as the cosine of the angle between them, equal to 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 · An embedding is a numerical vector representation of an item in a feature space, encoding selected properties or relationships for computational tasks such as comparison or retrieval.
- collaborative filteringpart of · Collaborative filtering is a recommendation technique that infers preferences or associations from interaction patterns among users, items, or other entities.
Questions about similarity matrix
What is similarity matrix?
A similarity matrix is a matrix whose entries quantify pairwise similarity between objects, items, data points, or their representations.
Which Manning books explain similarity matrix?
Data Without Labels, Natural Language Processing in Action, Second Edition and Graph Neural Networks in Action.
What should I know before learning similarity matrix?
Manning books that teach similarity matrix usually introduce embedding first.
What is the difference between similarity matrix and adjacency matrix?
A similarity matrix is a matrix whose entries quantify pairwise similarity between objects, items, data points, or their representations. 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.
What is similarity matrix part of?
Similarity matrix is part of collaborative filtering. Collaborative filtering is a recommendation technique that infers preferences or associations from interaction patterns among users, items, or other entities.
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.


