LocallyLinearEmbedding#

Use LLE when local barycentric reconstruction weights are expected to transfer to a low-dimensional manifold. Neighborhoods must be connected and locally nondegenerate.

import numpy as np
from believe14.nonlinear import LocallyLinearEmbedding
from _example_data import swiss_roll

X, _ = swiss_roll()
model = LocallyLinearEmbedding(n_components=2, n_neighbors=8, regularization=1e-3)
embedding = model.fit_transform(X)
assert embedding.shape == (54, 2)
assert not hasattr(model, "transform")  # only training reconstruction weights were derived
{
    "shape": embedding.shape,
    "weights": model.reconstruction_weights_.shape,
    "reconstruction_error": model.reconstruction_error_,
    "spectral_residual": model.diagnostics_.residual_norm,
}
{'shape': (54, 2),
 'weights': (54, 54),
 'reconstruction_error': 0.003926870850034923,
 'spectral_residual': 5.535324841244119e-16}

reconstruction_weights_, reconstruction_error_, and eigenvalues_ expose the local and global stages. Diagnostics check the alignment eigensystem. Degenerate neighborhoods and disconnected graphs fail explicitly; no nearest-neighbor interpolation is invented, so transform is absent.

Primary reference: [Roweis and Saul, 2000].