Nonlinear visualization
Visualizing data whose intrinsic structure is curved rather than linearly separable.
Scikit-Learn · Class
Isomap is a nonlinear dimensionality-reduction estimator that embeds data while preserving geodesic distances. It constructs shortest-path distances on a neighborhood graph and converts them into lower-dimensional coordinates.
Isomap builds a neighborhood graph for the training data, estimates shortest-path geodesic distances between points, and uses those distances to construct an embedding through an eigenvalue decomposition. New inputs are connected to training points through their nearest neighbors before their geodesic distances are computed.
class sklearn.manifold.Isomap(*, n_neighbors=5, radius=None, n_components=2, eigen_solver='auto', tol=0, max_iter=None, path_method='auto', neighbors_algorithm='auto', n_jobs=None, metric='minkowski', p=2, metric_params=None)| Name | Type | Description |
|---|---|---|
n_neighbors | int, default=5 | Number of neighbors used for each point; default 5. |
radius | float, default=None | Maximum radius of neighborhoods; default None. |
n_components | int, default=2 | Number of output coordinates; default 2. |
eigen_solver | {'auto', 'arpack', 'dense'}, default='auto' | Eigenvalue solver selection; default 'auto'. |
tol | float, default=0 | Tolerance for the eigenvalue solver; default 0. |
max_iter | int, default=None | Maximum number of eigenvalue-solver iterations; default None. |
path_method | {'auto', 'FW', 'D'}, default='auto' | Shortest-path algorithm selection; default 'auto'. |
neighbors_algorithm | {'auto', 'brute', 'kd_tree', 'ball_tree'}, default='auto' | Algorithm used for nearest-neighbor search; default 'auto'. |
n_jobs | int, default=None | Number of parallel jobs; default None. |
metric | str or callable, default='minkowski' | Distance metric for neighbors; default 'minkowski'. |
p | int, default=2 | Minkowski power parameter; default 2. |
metric_params | dict, default=None | Additional parameters for the distance metric; default None. |
fit_transform returns an array of shape (n_samples, n_components) containing the transformed coordinates.
from sklearn.datasets import make_swiss_roll
from sklearn.manifold import Isomap
X, _ = make_swiss_roll(n_samples=300, noise=0.05, random_state=0)
embedding = Isomap(n_neighbors=10, n_components=2).fit_transform(X)
print(embedding.shape)Generates Swiss-roll data and computes a two-dimensional Isomap embedding.
Visualizing data whose intrinsic structure is curved rather than linearly separable.
Creating compact features while retaining neighborhood-manifold geometry.
Comparing nonlinear embedding methods on synthetic or real datasets.
Isomap is a nonlinear dimensionality-reduction estimator that aims to preserve geodesic rather than straight-line distances. It first forms nearest-neighbor relationships, computes shortest paths on that graph, and derives coordinates from the resulting kernel.
Follow-up: How does path_method affect the computation? It selects the shortest-path algorithm, such as Dijkstra or Floyd-Warshall, used for graph distances.
n_neighbors controls how many training neighbors define the graph around each sample. n_components controls the number of coordinates in the final manifold representation.
Follow-up: What can happen with an unsuitable neighborhood size? A graph that is too sparse may not connect the data sufficiently for meaningful global geodesic distances.
fit_transform learns the Isomap representation from X and returns the transformed coordinates. transform maps new samples using their nearest training neighbors and shortest geodesic distances to the training set.
Follow-up: Why are training points needed during transform? The estimator uses the fitted neighborhood structure and training-derived geodesic information to connect new samples to the learned manifold.
sklearn.manifold.ClassicalMDSsklearn.manifold.LocallyLinearEmbeddingsklearn.manifold.SpectralEmbeddingsklearn.manifold.TSNEsklearn.manifold.MDS