Locally linear embedding (LLE) is an unsupervised, nonlinear dimensionality reduction algorithm that maps high-dimensional data to a low-dimensional space while preserving local linear relationships between each point and its nearest neighbors. In machine learning, a core discipline of artificial intelligence, LLE belongs to the family of manifold learning methods alongside Isomap, t-SNE and UMAP.
Introduced in 2000 by Sam Roweis and Lawrence Saul, LLE rests on one assumption: data lie on or near a smooth low-dimensional manifold, and every small neighborhood of that manifold is approximately flat. If each point can be rebuilt as a weighted average of its neighbors, the same weights should rebuild it in the reduced space as well.
How locally linear embedding works
LLE runs in three deterministic steps, and only the last step involves the target dimension. Because every step has a closed-form solution, the algorithm has no local minima and needs no learning rate or random initialization.
- Find neighbors: for each point, select its k nearest neighbors in the original space, usually by Euclidean distance.
- Compute reconstruction weights: solve a small constrained least-squares problem so that each point is best approximated by a weighted sum of its neighbors, with weights summing to one.
- Compute the embedding: find low-dimensional coordinates that are best reconstructed by the same fixed weights, which reduces to finding the bottom eigenvectors of a sparse matrix.
The weights are invariant to rotation, scaling and translation of each neighborhood. That invariance is the key insight: the weights describe intrinsic local geometry rather than absolute position, so they remain valid after the manifold is unrolled into fewer dimensions.
The final step builds the matrix M = (I – W)^T (I – W), discards the eigenvector with eigenvalue zero, which is constant, and uses the next d eigenvectors as the embedding coordinates. Sparse eigensolvers keep this step tractable for tens of thousands of points.
Key parameters and their effects
LLE has few hyperparameters, but each one strongly influences the result. Poor choices produce collapsed or folded embeddings rather than graceful degradation.
| Parameter | Typical range | Effect when changed |
|---|---|---|
| Number of neighbors k | 5 to 30 | Too small fragments the manifold, too large ignores curvature |
| Target dimension d | 2 to 10 | Must be smaller than k for stable weights |
| Regularization term | About 1e-3 times the local trace | Stabilizes weights when k exceeds input dimension |
| Neighbor search method | Exact or approximate | Trades accuracy for speed on large data |
Regularization is essential whenever k is greater than the input dimension, because the local Gram matrix then becomes singular and infinitely many weight vectors fit perfectly. Without it, the weights become unstable and the embedding turns noisy.
Variants of LLE
Several variants address the instability and distortion of standard LLE. They keep the neighborhood idea but change how local geometry is captured.
| Variant | Main idea | When to prefer it |
|---|---|---|
| Standard LLE | Single weight vector per point | Quick baseline on clean data |
| Modified LLE (MLLE) | Multiple weight vectors per neighborhood | When standard LLE collapses or distorts |
| Hessian LLE | Local Hessian estimates of curvature | Locally isometric manifolds, higher cost |
| Local tangent space alignment (LTSA) | Aligns local tangent coordinates | Smooth manifolds with moderate noise |
| Kernel and supervised LLE | Kernelized or label-aware neighbors | Feature extraction for classification |
Modified LLE is often the safest default among these variants. Standard LLE tends to squeeze the embedding toward a few dominant directions when neighborhoods are poorly conditioned, and MLLE counters this by using several orthogonal weight vectors per point. Hessian LLE and LTSA give more faithful geometry on locally isometric data, but they need more neighbors than standard LLE and cost noticeably more memory and time.
Computational cost grows with both sample size and neighborhood size. Neighbor search dominates for high-dimensional inputs, while the sparse eigenvalue problem dominates for large sample counts. Datasets above roughly 100,000 points usually call for approximate neighbor search, subsampling with landmark points, or a different method altogether.
LLE compared with other dimensionality reduction methods
LLE preserves local reconstruction structure, whereas other methods preserve variance, geodesic distances or neighbor probabilities. The right choice depends on what the downstream task needs from the embedding.
| Method | What it preserves | Out-of-sample mapping | Typical use |
|---|---|---|---|
| Principal component analysis | Global variance, linear | Direct projection | Fast linear baseline |
| Isomap | Geodesic distances | Approximate only | Global shape of manifolds |
| Locally linear embedding | Local linear weights | Approximate only | Smooth, well-sampled manifolds |
| t-SNE | Neighbor probabilities | Not native | Cluster visualization |
| UMAP | Fuzzy neighborhood graph | Supported | Scalable visualization and features |
LLE scales better than Isomap because it avoids computing all-pairs shortest paths, but it is less robust than UMAP on noisy real-world data. Many practitioners now use LLE mainly for teaching, benchmarking and smooth synthetic manifolds.
Limitations and practical advice
LLE works well only when the manifold is densely and uniformly sampled. Sparse regions, holes, noise and several disconnected clusters break the assumption that neighborhoods are small, flat patches of one connected surface.
- Disconnected neighbor graphs produce meaningless embeddings, so check graph connectivity before trusting the output.
- Feature scaling matters, because Euclidean neighbors change when one feature dominates numerically.
- No native out-of-sample extension exists; new points need an approximate weight-based mapping.
- Distorted global geometry is common, since LLE preserves local structure but not distances between distant regions.
- Run a parameter sweep over k and compare results with a trustworthiness or continuity score.
In plain words
Picture a rolled-up paper map. Two towns may be close through the air but far apart along the paper. Locally linear embedding tries to unroll the map without tearing it.
It does this by looking at small patches. Each point remembers how it relates to a few close neighbors. The method then lays all points flat so that every point keeps those same neighbor relationships. The big picture may bend a little, but small neighborhoods stay intact.
A real-world example
A research team studies a set of 2,000 grayscale face images, each 64×64 pixels, so every image is a point in a 4,096-dimensional space. The images show one person turning the head left and right and looking up and down under steady lighting.
The team scales the pixel values, runs LLE with k = 12 neighbors and a target dimension of two, and adds the standard regularization term. The resulting two-dimensional map arranges the faces smoothly: one axis follows left-right head rotation and the other follows up-down tilt.
Principal component analysis on the same data mixes pose with lighting variation, whereas LLE recovers the two pose directions clearly. The team then uses the embedding to select evenly spaced poses for a training set, which reduces redundant images by about a third.