Implementation:Scikit learn Scikit learn Isomap
| Knowledge Sources | |
|---|---|
| Domains | Machine Learning, Dimensionality Reduction |
| Last Updated | 2026-02-08 15:00 GMT |
Overview
Concrete tool for non-linear dimensionality reduction through Isometric Mapping provided by scikit-learn.
Description
This module implements the Isomap algorithm for non-linear dimensionality reduction. Isomap extends classical Multidimensional Scaling (MDS) by replacing Euclidean distances with geodesic distances computed on a nearest-neighbor graph. It first constructs a k-nearest neighbor or radius-based graph, computes shortest path distances between all pairs of points, and then applies Kernel PCA with a precomputed distance kernel. The algorithm preserves the global geometric structure of the data manifold.
Usage
Use Isomap when your data lies on a non-linear manifold and you want to preserve geodesic distances in the low-dimensional embedding. It works well when the data manifold is globally connected and approximately isometric to Euclidean space.
Code Reference
Source Location
- Repository: scikit-learn
- File: sklearn/manifold/_isomap.py
Signature
class Isomap(ClassNamePrefixFeaturesOutMixin, TransformerMixin, BaseEstimator):
"""Isomap Embedding."""
def __init__(
self,
*,
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,
):
...
Import
from sklearn.manifold import Isomap
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| X | array-like of shape (n_samples, n_features) | Yes | Training data |
| n_neighbors | int or None | No | Number of neighbors for graph construction (default: 5) |
| radius | float or None | No | Radius for radius-based graph (alternative to n_neighbors) |
| n_components | int | No | Target dimensionality (default: 2) |
| eigen_solver | str | No | Eigenvalue solver: 'auto', 'arpack', or 'dense' (default: 'auto') |
| path_method | str | No | Shortest path algorithm: 'auto', 'FW', or 'D' (default: 'auto') |
| metric | str | No | Distance metric for neighbors (default: 'minkowski') |
Outputs
| Name | Type | Description |
|---|---|---|
| embedding_ | ndarray of shape (n_samples, n_components) | Low-dimensional embedding of training data |
| kernel_pca_ | KernelPCA | Internal KernelPCA instance used for the embedding |
| dist_matrix_ | ndarray of shape (n_samples, n_samples) | Geodesic distance matrix |
| nbrs_ | NearestNeighbors | Internal NearestNeighbors instance |
Usage Examples
Basic Usage
from sklearn.manifold import Isomap
from sklearn.datasets import make_swiss_roll
# Generate Swiss roll data
X, color = make_swiss_roll(n_samples=1000, random_state=42)
# Apply Isomap
isomap = Isomap(n_neighbors=10, n_components=2)
X_embedded = isomap.fit_transform(X)
print("Embedded shape:", X_embedded.shape)
print("Reconstruction error:", isomap.reconstruction_error())