Isomap

Basic

Isomap | Unroll nonlinear manifolds

Isomap (Isometric Mapping) preserves geodesic distances on a neighbour graph so that Multiples Dimensional Scaling (MDS) can flatten curved manifolds such as the Swiss roll.


1. Idea #

  1. Build a neighbour graph with either a fixed number of neighbours (k) or a radius (\varepsilon).
  2. Compute the shortest-path (geodesic) distances along that graph for every pair of samples.
  3. Feed the resulting distance matrix to classical MDS to obtain the low-dimensional embedding.

This workflow keeps far-apart regions separated while unrolling the curved surface.


2. Python example #

import numpy as np
import matplotlib.pyplot as plt
import japanize_matplotlib
from sklearn.datasets import make_swiss_roll
from sklearn.manifold import Isomap

X, color = make_swiss_roll(n_samples=1500, noise=0.05, random_state=0)
iso = Isomap(n_neighbors=10, n_components=2)
emb = iso.fit_transform(X)

fig, axes = plt.subplots(1, 2, figsize=(12, 5))
axes[0].scatter(X[:, 0], X[:, 2], c=color, cmap="Spectral", s=5)
axes[0].set_title("Original Swiss roll")
axes[1].scatter(emb[:, 0], emb[:, 1], c=color, cmap="Spectral", s=5)
axes[1].set_title("Isomap embedding")
for ax in axes:
    ax.set_xticks([])
    ax.set_yticks([])
plt.tight_layout()
plt.show()

Isomap demo


3. Hyperparameters #

  • n_neighbors: governs the local neighbourhood; too small breaks the graph, too large washes out the manifold structure.
  • n_components: usually 2 or 3 for visualisation, but higher values are possible.
  • Handle duplicates/noisy samples by scaling features or adding slight noise before building the graph.

4. Pros and cons #

ProsCons
Preserves manifold structure and distancesSensitive to noisy neighbour graphs
Produces intuitive visualisationsRequires computing all-pairs shortest paths

5. Notes #

  • Isomap = neighbourhood graph + MDS; pick neighbours carefully to reflect the true topology.
  • Inspect the connected components of the graph: isolated points will distort the embedding.
  • Consider UMAP or t-SNE if you need faster embeddings or better preservation of local densities.