Isomap#

Use Isomap when geodesic distance on a connected sampled manifold should unfold into Euclidean coordinates. Exact neighbor count controls the geometry and must connect the graph without creating excessive shortcuts.

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

X, roll_coordinate = swiss_roll()
model = Isomap(n_components=2, n_neighbors=8)
embedding = model.fit_transform(X)
assert embedding.shape == (54, 2)
assert not hasattr(model, "transform")  # no interpolation is added to paper Isomap
{
    "shape": embedding.shape,
    "geodesic_matrix": model.geodesic_distances_.shape,
    "leading_eigenvalues": np.round(model.eigenvalues_[:2], 3).tolist(),
    "diagnostic_warnings": model.diagnostics_.warnings,
}
{'shape': (54, 2),
 'geodesic_matrix': (54, 54),
 'leading_eigenvalues': [91.416, 89.945],
 'diagnostic_warnings': ('The dissimilarities are non-Euclidean; the full Gram spectrum contains significant negative eigenvalues.',)}

geodesic_distances_, eigenvalues_, and embedding_ expose both algorithm stages. Diagnostics report the classical-scaling residual and warn about non-Euclidean geodesics. Duplicate observations or a disconnected exact graph are rejected; this transductive class intentionally has no transform.

Primary reference: [Tenenbaum et al., 2000].