Foundations to Frontier
Tests
D. Classical Machine Learning › D9 Dimensionality Reduction and Manifold Learning

Locally Linear Embedding (LLE)

Locally linear embedding (Roweis and Saul, 2000) assumes each data point and its neighbours lie on a nearly flat patch of a manifold. It describes every point as a weighted average of its k nearest neighbours, with weights summing to one, then finds low-dimensional coordinates that the same weights reconstruct as well as possible. Both steps are closed-form: a small regularised linear solve per point, and the bottom eigenvectors of the sparse matrix (I − W)ᵀ(I − W). The weights are invariant to rotation, scaling and translation, so they capture local geometry only. LLE needs no shortest paths and scales to large data, but its embedding is normalised to unit covariance, which discards aspect ratio and lets 'harmonic' eigenvectors displace genuine coordinates, and it is sensitive to the regularisation and to k. This page covers the weight and embedding steps, invariances, the role of regularisation, the normalisation problem, and modified, Hessian and LTSA variants. In the exercises you implement LLE and unroll a Swiss roll's arc length that PCA cannot; then you track where the roll's height coordinate goes as regularisation changes.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Describe each point by its neighbours

Imagine describing your house’s position only relative to your neighbours: “halfway between the Smiths and the Lees, a little toward the park”. LLE writes such a recipe for every data point, as a weighted average of its few nearest neighbours. Then it lays all the points out on a flat sheet so that every recipe still works. Because each recipe is local, the sheet can follow a curved, rolled-up surface.

LLE: rebuild each point from its neighbours, keep the weights, flatten
coloured by arc lengthcoloured by height
2-D embedding explains (R²): arc length 0.43 · height 0.27 · height with a 3rd coordinate 0.96
e1: arc 0.11, height 0.02 · e2: arc 0.32, height 0.25 · e3: arc 0.14, height 0.69 · e4: arc 0.23, height 0.03 · e5: arc 0.08, height 0.00
With strong regularisation (1e−2 or more here) the first coordinate tracks arc length, but the second is usually a wave along the arc rather than the height: the left plot shows a curve, and the height turns up only in a later eigenvector. With almost no regularisation the weights rebuild each point exactly in 3-D, every straight-line coordinate costs nothing, and LLE behaves almost linearly: height appears, arc length is lost. In between, results swing from sample to sample (try new sample), because the bottom eigenvalues are tiny and nearly equal. Where the switch happens depends on the sample size; with 700 points (exercise 2) it was already at 1e−3.
Why engineers care

LLE needs only nearest neighbours and a sparse eigenproblem, with no all-pairs shortest paths, so it scales well and suits data whose small neighbourhoods are trustworthy while long-range distances are not, such as images under smoothly varying pose or sensor signatures across a slowly changing operating condition. Its weakness, shown in the demo, is that the embedding can be dominated by the wrong eigenvectors, so results must be checked.

📝 Quick check (Level 0)
0/3 answered
  1. 1. LLE describes each point as…
  2. 2. LLE keeps… while flattening.
  3. 3. Does LLE need shortest paths through a graph?

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

The two steps by hand

Step 1: weights. For point xᵢ with neighbours z₁ … z_k, minimise ‖xᵢ − Σⱼ wⱼzⱼ‖² subject to Σⱼ wⱼ = 1.

  • A point a quarter of the way from neighbour A to neighbour B gets weights (0.75, 0.25); the midpoint gets (0.5, 0.5).
  • For x = (1, 1) with neighbours (0, 0), (2, 0), (0, 2), the weights (0, 0.5, 0.5) rebuild x exactly, so the first weight is 0.

The solution uses the local Gram matrix Cⱼₗ = (zⱼ − xᵢ)·(zₗ − xᵢ): solve Cw = 1 and rescale w to sum to 1. With k = 10 neighbours in 3-D, C has rank at most 3, so it is singular. A ridge term, C + reg · tr(C) · I, makes the solution unique.

Step 2: embedding. Find coordinates yᵢ minimising Σᵢ‖yᵢ − Σⱼ Wᵢⱼyⱼ‖² = tr(YᵀMY), with M = (I − W)ᵀ(I − W). To rule out the trivial answer, require centred coordinates with identity covariance. The solution is the eigenvectors of M with the smallest eigenvalues, discarding the very smallest (the constant vector, eigenvalue 0).

Reconstruction error. For points 0, 1, 2 on a line where the middle is rebuilt from both ends and each end from the middle, the errors are 1, 0, 1, so the mean is 2/3 = 0.667.

The steps in plain English:

  1. Find k nearest neighbours of each point.
  2. Solve a small regularised k × k system per point for weights summing to 1.
  3. Build the sparse matrix M = (I − W)ᵀ(I − W).
  4. Take eigenvectors 2 … d + 1 of M, from the bottom, as coordinates.
  5. Check: colour by any known variable, try several k and reg values, and look at a few more eigenvectors than you need.
📝 Quick check (Level 1)
0/3 answered
  1. 1. LLE weights for each point sum to…
  2. 2. Why is regularisation needed when k exceeds the data dimension?
  3. 3. Which eigenvector of M is discarded?

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.

Invariances, normalisation and regularisation

Invariance. Rotating, scaling or translating a neighbourhood leaves the weights unchanged: rotation and scaling keep the Gram matrix’s shape, and the sum-to-one constraint cancels translation. The weights therefore encode only local geometry, which is what lets LLE unroll curved sheets. Exercise 1 confirmed this numerically.

Exercise 1 (600-point Swiss roll, k = 10, reg = 10⁻³):

  • rank correlation of the first LLE coordinate with arc length 1.000, against 0.251 for the best PCA axis;
  • mean squared reconstruction error 0.0035, against 1.02 for the squared nearest-neighbour distance;
  • bottom eigenvalues of M: 0 (the constant vector), then 1.4 × 10⁻⁹, 4.7 × 10⁻⁷ and 5.3 × 10⁻⁷.

The non-trivial eigenvalues are tiny and close together, which is a warning sign: small perturbations can reorder the corresponding eigenvectors.

The normalisation problem. The constraint YᵀY = I gives every output coordinate the same variance, so LLE cannot represent a sheet that is four times longer than wide. Worse, a second, slower “wave” along the long direction, such as cos(2π · arc length), can cost less than the genuine short coordinate (height) and take its place among the bottom eigenvectors. This is the “price of normalisation” (Goldberg et al., 2008), shared with Laplacian eigenmaps.

Regularisation changes the method. With reg → 0 and k larger than the ambient dimension, the weights can rebuild each point exactly in the ambient coordinates. Then every linear function of x, including the straight-line height, costs nothing, and LLE behaves almost like a linear projection. With larger reg the weights spread more evenly and LLE behaves like a graph Laplacian, which finds smooth functions along the manifold, arc length first.

from sklearn.manifold import LocallyLinearEmbedding
Y = LocallyLinearEmbedding(n_neighbors=10, n_components=2, reg=1e-3, method="standard").fit_transform(X)
# method="modified", "hessian" or "ltsa" are more stable variants
🐍 Exercise 1: LLE on the Swiss roll
Implement regularised LLE weights and the bottom-eigenvector embedding; check that weights sum to 1 and are invariant to rotation, scaling and translation, and compare the rank correlation of the first coordinate with arc length against PCA.
📝 Quick check (Level 2)
0/3 answered
  1. 1. LLE's embedding has, by construction,…
  2. 2. With almost no regularisation (k > D), LLE tends to behave like…
  3. 3. Tiny, nearly equal bottom eigenvalues mean…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

What operator does LLE approximate? Under suitable scaling, the matrix M behaves like a differential operator on the manifold, but which one depends on the regularisation. Wu and Wu (2018) showed that only with an appropriately chosen regulariser does LLE converge to the Laplace–Beltrami operator, the same limit as Laplacian eigenmaps. With too small a regulariser, LLE picks up the ambient geometry instead. Belkin and Niyogi (2003) gave an earlier heuristic link between LLE and the iterated Laplacian.

Variants.

  • Modified LLE (Zhang and Wang, 2007) uses several weight vectors per point, from the null space of the local Gram matrix, which stabilises the solution when k > D.
  • Hessian LLE (Donoho and Grimes, 2003) penalises local Hessians and recovers coordinates exactly for manifolds locally isometric to an open connected set, even non-convex ones.
  • LTSA (Zhang and Zha, 2004) aligns local tangent-space coordinates globally.

Cost. Neighbour search costs about n log n with trees; the weights cost n·k³; the eigenproblem is sparse, with about n·k² non-zeros, and only the bottom d + 1 eigenvectors are needed, using shift-invert Lanczos.

Interview questions.

  • LLE or Isomap? Isomap preserves global geodesic distances when the manifold is convex and well sampled; LLE is local, cheaper and avoids shortest paths, but loses scale and is prone to eigenvector mixing. In practice, try Hessian LLE or LTSA if you want LLE’s locality with more stability.
  • Why might LLE’s second coordinate be useless? Normalisation lets a harmonic of the first coordinate take its place. Inspect more eigenvectors, or use a variant that avoids the problem.
📝 Quick check (Level 3)
0/3 answered
  1. 1. Hessian LLE can handle…
  2. 2. Whether LLE approximates the Laplace–Beltrami operator depends on…
  3. 3. LLE's eigenproblem is…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

Where did the height go?

History.

  • S. Roweis and L. Saul (2000) introduced LLE in Science, in the same issue as Isomap.
  • D. Donoho and C. Grimes (2003) introduced Hessian eigenmaps.
  • Z. Zhang and H. Zha (2004) introduced LTSA, and Z. Zhang and J. Wang (2007) modified LLE.
  • Y. Goldberg, A. Zakai, D. Kushnir and Y. Ritov (2008) analysed the price of normalisation.
  • H.-T. Wu and N. Wu (2018) gave the asymptotic analysis of LLE and its regulariser.

Exercise 2. A 700-point Swiss roll, k = 10, 3 datasets. For each regularisation, the table shows:

  • R² of a linear fit of the true arc length and height from the first two LLE coordinates;
  • R² of height from the first three coordinates;
  • the squared correlation of the second coordinate with cos(2π · scaled arc length), a “wave” along the roll;
  • which eigenvector (1 = first non-constant) correlates best with height, averaged.
reg arc length, 2-D height, 2-D height, 3-D 2nd coordinate as a wave height’s eigenvector
10⁻⁶ 0.07 0.99 1.00 0.06 1.0
10⁻⁴ 0.98 0.42 0.94 0.41 2.3
10⁻³ 1.00 0.23 0.85 0.57 2.7
10⁻² 1.00 0.03 0.66 0.83 3.0
10⁻¹ 0.99 0.00 0.21 0.88 4.0
  • No setting recovered both coordinates in 2-D. With almost no regularisation LLE found the height, a straight-line ambient coordinate, and lost the arc length: it behaved like a linear method.
  • With the common default (10⁻³) and above, the first coordinate was arc length and the second was mostly a wave along it, pushing height to the third or a later eigenvector; at 10⁻¹, the fourth.
  • Height was linearly recoverable from three coordinates only for small regularisation. As reg grew, it spread over later eigenvectors and the 3-D R² fell to 0.21.
  • The practical rule: compute several more eigenvectors than you need, identify them by colouring or correlating with known variables, and prefer a stable variant (modified or Hessian LLE, or LTSA) when the manifold is elongated.
🐍 Exercise 2 (research): regularisation and the missing coordinate
For regularisation 1e−6 … 1e−1 on a 700-point Swiss roll, compute LLE's first six non-constant eigenvectors and measure how well the first two (and three) explain arc length and height, how wave-like the second coordinate is, and which eigenvector carries the height.

LLE in AI, robotics and aerospace

  • Pose manifolds from images: low-dimensional coordinates for face, object or spacecraft pose from image patches, as a first look before supervised learning.
  • Operating-condition maps: embed sensor snapshots so that slowly varying conditions such as altitude or temperature appear as smooth coordinates.
  • Motion data: embed motion-capture or robot joint trajectories for gait-phase analysis.

References

  1. S. T. Roweis, L. K. Saul (2000). “Nonlinear dimensionality reduction by locally linear embedding.” Science 290(5500).
  2. D. L. Donoho, C. Grimes (2003). “Hessian eigenmaps: locally linear embedding techniques for high-dimensional data.” PNAS 100(10).
  3. Z. Zhang, H. Zha (2004). “Principal manifolds and nonlinear dimensionality reduction via tangent space alignment.” SIAM Journal on Scientific Computing 26(1).
  4. Y. Goldberg, A. Zakai, D. Kushnir, Y. Ritov (2008). “Manifold learning: the price of normalization.” Journal of Machine Learning Research 9.
  5. H.-T. Wu, N. Wu (2018). “Think globally, fit locally under the manifold setup: asymptotic analysis of locally linear embedding.” Annals of Statistics 46(6B).