AI Glossary / Probabilistic machine learning / Intermediate
Stochastic neighbor embedding
Definition
Stochastic neighbor embedding, or SNE, is a nonlinear dimensionality-reduction method that represents objects in a lower-dimensional space by trying to preserve their probabilistic neighborhood relationships. It converts similarities around each object into a distribution over possible neighbors, then adjusts the low-dimensional positions to approximate those distributions.
What it means
A two-dimensional map cannot usually preserve every relationship in a high-dimensional dataset. SNE focuses on which objects are likely neighbors rather than requiring every original distance to remain unchanged.
The basic method constructs a separate conditional neighbor distribution for each object. These distributions can be asymmetric: object A assigning high probability to B does not require B to assign the same probability to A. The probabilities express similarity under the chosen representation and scale; they are not probabilities that two objects share a real-world category or causal relationship.
How it works
For each input object i, compute weights for other objects using an exponential of negative scaled squared distance, then normalize the weights to obtain probabilities p(j given i). Exclude the object itself. A local scale can be chosen to obtain a desired perplexity, which summarizes the distribution's effective neighborhood size.
Place each object at a low-dimensional position. The basic SNE method defines another conditional neighbor distribution q(j given i) using Gaussian-shaped similarities in that space. It minimizes the sum, over input objects, of KL divergences from p to q.
Optimization moves positions so that neighbors important in the input representation retain substantial probability in the map. The objective is nonconvex, so initialization and optimization choices matter. Basic SNE differs from t-SNE, which changes the low-dimensional similarity and uses a related symmetric formulation. Neither method makes a visual grouping a verified class label.
Three practical examples
1. Document exploration: create a map from document feature vectors and inspect local neighborhoods. Read representative documents before naming a topic or assuming that empty map space implies a strong semantic boundary.
2. Product comparison: visualize engineered product attributes after scaling them appropriately. Check whether nearby items are useful alternatives using the original attributes, not only their plotted positions.
3. Representation inspection: explore image feature vectors to find unusual local neighborhoods. Use the map to select examples for review, while measuring retrieval or classification quality separately on appropriate evaluation data.
Think of it this way
Think of arranging people on a seating chart using each person's list of likely conversation partners. The aim is to retain important neighbor relationships, not reproduce everyone's original geographic distance. One person's strongest preference may not be reciprocated equally. The arrangement is informative, but its geometry is a compromise.
Worked example
Consider an original calculation for one row of SNE's objective. Object A has only two candidate neighbors, B and C, and its input conditional probabilities are 0.8 and 0.2. Suppose the map currently assigns probabilities 0.5 and 0.5 because B and C are equally distant from A.
Using natural logarithms, this row contributes 0.8 ln(0.8 divided by 0.5) + 0.2 ln(0.2 divided by 0.5), approximately 0.1927 nats. If the map reverses the preference and assigns 0.2 to B and 0.8 to C, the contribution becomes 0.8 ln 4 + 0.2 ln 0.25, approximately 0.8318 nats. Matching 0.8 and 0.2 would make the row contribution zero.
Under q weights proportional to exp of negative squared map distance, matching the row requires C's squared distance from A to exceed B's by ln 4, approximately 1.3863. This is a relation between distances, not a unique arrangement.
The whole embedding must also account for B's and C's own neighbor distributions. Improving A's row alone may worsen other rows. This calculation illustrates a local objective contribution and does not claim to solve an entire SNE optimization problem.
Illustrative case study
Fictional case: Willow Library wants an exploratory map of support articles. Its analysts generate document vectors, remove duplicate records, and inspect how different feature scaling and neighborhood settings affect the map. They retain the same set of articles while comparing runs so that changes can be interpreted.
Editors open articles in suspicious neighborhoods and check the original similarity scores. A visually isolated group becomes a review candidate, not an automatic category assignment. The team records which groupings persist across reasonable settings and which disappear. This fictional case describes a cautious exploration workflow without claiming measured improvements in search or editorial productivity.
Common misconceptions and mistakes
SNE does not preserve all global distances or provide meaningful named axes by default. A nearby pair on a map is not proof of shared labels, and a gap is not a statistical significance test. Perplexity is an effective neighborhood parameter, not a required number of clusters. Also avoid calling every neighborhood visualization t-SNE when the underlying algorithm is basic SNE.
Business use
The practical benefit is making complex representations easier to inspect and discuss. The main risk is overinterpreting an appealing map. Business reports should identify the input representation, scaling, neighborhood settings, and algorithm variant. Any resulting segmentation or operational decision needs separate validation in the original problem space. Visualization can suggest questions and review priorities; it does not supply the answer to every one of them.
People also ask
Why is it called stochastic?
Neighborhood relationships are represented probabilistically; the method is not defined merely by random initialization.
Are the neighbor probabilities symmetric?
Not in the basic conditional formulation.
Can map axes be interpreted as original features?
Generally no. The learned coordinates are chosen to support the embedding objective rather than to preserve named feature meanings.
Check your understanding
Answer: 1.
Which row has lower cost in the example: equal neighbors or reversed preference?
Answer: Equal neighbors, with about 0.1927 rather than 0.8318 nats.
Answer: 2.
Does matching one row guarantee a perfect embedding?
Answer: No; all rows must be considered together.
Answer: 3.
Why inspect the original records?
Answer: The map may distort relationships and depends on the chosen representation.
Related terms
- Dimensionality reduction
- Symmetric stochastic neighbor embedding
- Perplexity
- Manifold Learning
- t-SNE
- KL divergence
- neighborhood preservation
Learn next
Calculate neighbor probabilities from a small distance matrix. Then examine the effects of local scale and KL direction, followed by the differences between basic SNE, symmetric SNE, and t-SNE.
More in Probabilistic machine learning
- Statistical linear regression - Statistical linear regression, in nonlinear Bayesian estimation, approximates a relationship between uncertain variables by an affine transformation plus an...
- Stein discrepancy - A Stein discrepancy measures how strongly a candidate distribution violates identities that should hold under a target probability distribution.
- Stochastic gradient Hamiltonian Monte Carlo - Stochastic gradient Hamiltonian Monte Carlo, or SGHMC, is a posterior sampling method that combines momentum-based dynamics with gradients estimated from...
- Stochastic variational inference - Stochastic variational inference, or SVI, uses stochastic optimization to fit a tractable approximation to a Bayesian posterior distribution.
- Stochastic weight averaging - Stochastic weight averaging, or SWA, forms a single neural-network model by taking an equal average of selected parameter vectors along a training trajectory.
- Stochastic weight averaging Gaussian approximation - Stochastic weight averaging Gaussian approximation, usually called SWA-Gaussian or SWAG, fits a Gaussian distribution over neural-network parameters using...
Sources
Hinton and Roweis, Stochastic Neighbor Embedding, introduces the conditional neighborhood formulation and KL objective: https://www.cs.toronto.edu/~hinton/absps/sne.pdf
The single-row calculation and Willow Library case are original teaching examples; the case is fictional.
Independent review consulted Section 2, Equations 1–4, of the original SNE paper.
Previous: Stochastic multiarmed bandit Next: Stochastic parrot