Manifold visualization
Visualizing high-dimensional samples in two or three coordinates.
Scikit-Learn · Class
LocallyLinearEmbedding learns a low-dimensional representation by preserving local neighborhood relationships. Its method parameter supports standard, Hessian, modified, and local tangent-space alignment variants.
The estimator finds each sample’s nearest neighbors, computes weights that reconstruct the sample from that local neighborhood, and then chooses a low-dimensional representation that preserves those local reconstruction relationships. The selected method controls the LLE variant, while the estimator exposes the result through fit_transform and reports reconstruction_error_.
class sklearn.manifold.LocallyLinearEmbedding(*, n_neighbors=5, n_components=2, reg=0.001, eigen_solver='auto', tol=1e-06, max_iter=100, method='standard', hessian_tol=0.0001, modified_tol=1e-12, neighbors_algorithm='auto', random_state=None, n_jobs=None)| Name | Type | Description |
|---|---|---|
n_neighbors | int | Number of neighbors used to construct each local neighborhood; default 5. |
n_components | int | Number of coordinates in the learned embedding; default 2. |
reg | float | Regularization constant applied to the local covariance trace; default 0.001. |
eigen_solver | str | Eigenvalue-decomposition strategy, such as auto or dense; default auto. |
tol | float | Tolerance for the eigenvalue solver; default 1e-6. |
max_iter | int | Maximum number of eigenvalue-solver iterations; default 100. |
method | str | Embedding algorithm: standard, hessian, modified, or ltsa; default standard. |
hessian_tol | float | Tolerance used by the Hessian eigenmapping method; default 1e-4. |
modified_tol | float | Tolerance used by modified LLE; default 1e-12. |
neighbors_algorithm | str | Nearest-neighbor search algorithm; default auto. |
random_state | int, RandomState instance or None | Controls randomness where applicable; default None. |
n_jobs | int or None | Number of parallel jobs; default None. |
fit_transform returns the input samples represented in n_components dimensions; fitting also provides reconstruction_error_.
from sklearn.datasets import load_digits
from sklearn.manifold import LocallyLinearEmbedding
X, _ = load_digits(return_X_y=True)
embedding = LocallyLinearEmbedding(n_components=2, random_state=0)
X_2d = embedding.fit_transform(X)
print(X_2d.shape)
Fits a two-dimensional LLE representation of the handwritten-digits samples and prints the transformed shape.
Visualizing high-dimensional samples in two or three coordinates.
Compressing nonlinear data while retaining local geometry.
Comparing alternative local manifold algorithms on the same dataset.
LLE preserves local neighborhood structure rather than global pairwise distances. Standard LLE performs nearest-neighbor search, constructs local reconstruction weights, and solves a partial eigenvalue problem for the embedding.
Follow-up: How does the modified variant differ operationally? The documentation identifies modified LLE as a separate algorithm selected with method='modified'.
The method parameter selects standard, hessian, modified, or ltsa. The default is standard, and each option represents a different locally based embedding procedure.
Follow-up: Which setting enables local tangent space alignment? Set method='ltsa'.
n_neighbors controls the local neighborhood size, while n_components specifies the number of output coordinates. The hessian variant additionally requires a sufficiently large neighborhood relative to the requested dimensionality.
Follow-up: What should be checked when a Hessian configuration fails? Verify the documented inequality between n_neighbors and n_components.
locally_linear_embeddingIsomapMDSSpectralEmbeddingTSNE