LocalTangentSpaceAlignment#
Use LTSA when local tangent-plane coordinates can be aligned into a global manifold chart. Each exact neighborhood must contain enough independent local variation for the requested dimension.
import numpy as np
from believe14.nonlinear import LocalTangentSpaceAlignment
from _example_data import swiss_roll
X, _ = swiss_roll()
model = LocalTangentSpaceAlignment(n_components=2, n_neighbors=8)
embedding = model.fit_transform(X)
assert embedding.shape == (54, 2)
assert not hasattr(model, "transform") # alignment was solved only for fitted vertices
{
"shape": embedding.shape,
"alignment_matrix": model.alignment_matrix_.shape,
"eigenvalues": np.round(model.eigenvalues_, 6).tolist(),
"alignment_residual": model.diagnostics_.residual_norm,
}
{'shape': (54, 2),
'alignment_matrix': (54, 54),
'eigenvalues': [0.179202, 0.213851],
'alignment_residual': 8.048581811647286e-16}
alignment_matrix_, eigenvalues_, and embedding_ expose the global solve.
Diagnostics check its eigensystem. Rank-deficient tangent neighborhoods and a
disconnected graph are explicit failures. LTSA is transductive and provides
coordinates for the fitted observations.
Primary reference: [Zhang and Zha, 2004].