Implementation:DistrictDataLabs Yellowbrick Manifold Visualizer
| Knowledge Sources | |
|---|---|
| Domains | Machine_Learning, Feature_Analysis, Visualization |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for manifold learning-based dimensionality reduction and scatter plot visualization provided by the Yellowbrick library.
Description
The Manifold visualizer embeds high-dimensional feature data into 2D (or 3D) space using one of several scikit-learn manifold learning algorithms, then renders the result as a scatter plot colored by the target variable. It supports eight built-in algorithms selectable by string name: "lle", "ltsa", "hessian", "modified", "isomap", "mds", "spectral", and "tsne". Alternatively, a custom scikit-learn transformer can be passed directly. The visualizer records the fit time and displays it in the plot title. Both discrete (classification) and continuous (regression) targets are supported, with a legend or colorbar drawn accordingly.
Usage
Use the Manifold visualizer to explore non-linear structure in feature data that PCA cannot capture. It is especially useful for comparing how different embedding algorithms reveal clusters or patterns. Note that some algorithms (t-SNE, MDS, SpectralEmbedding) do not support a separate transform call and require fit_transform instead. The visualizer raises a ModelError if fit is called on such an algorithm.
Code Reference
Source Location
- Repository: yellowbrick
- File: yellowbrick/features/manifold.py
- Lines: Manifold class at L66-464, quick method at L472-619
Signature
class Manifold(ProjectionVisualizer):
def __init__(
self,
ax=None,
manifold="mds",
n_neighbors=None,
features=None,
classes=None,
colors=None,
colormap=None,
target_type="auto",
projection=2,
alpha=0.75,
random_state=None,
colorbar=True,
**kwargs
):
Import
from yellowbrick.features import Manifold
Supported Algorithms
| String Key | Algorithm | Description |
|---|---|---|
"lle" |
LocallyLinearEmbedding (standard) | Standard Locally Linear Embedding |
"ltsa" |
LocallyLinearEmbedding (ltsa) | Local Tangent Space Alignment LLE |
"hessian" |
LocallyLinearEmbedding (hessian) | Hessian Eigenmapping LLE |
"modified" |
LocallyLinearEmbedding (modified) | Modified LLE |
"isomap" |
Isomap | Isometric Mapping |
"mds" |
MDS | Multi-Dimensional Scaling |
"spectral" |
SpectralEmbedding | Spectral Embedding via graph Laplacian |
"tsne" |
TSNE | t-distributed Stochastic Neighbor Embedding |
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| ax | matplotlib Axes | No | The axes to plot on. If None, current axes are used or generated. |
| manifold | str or Transformer | No | Manifold algorithm: a string key from the table above or a scikit-learn transformer. Default "mds".
|
| n_neighbors | int or None | No | Number of neighbors for neighbor-based algorithms. Defaults to 5 (or higher for hessian) if not specified and algorithm requires it.
|
| features | list | No | Feature names. Inferred from DataFrame columns if not provided. |
| classes | list | No | Class labels for the legend (discrete target only). Inferred from y if not provided. |
| colors | list or tuple | No | Colors for each class or a single color for all points. |
| colormap | str or cmap | No | Matplotlib colormap for coloring points. |
| target_type | str | No | Target type: "auto" (default), "discrete", or "continuous".
|
| projection | int | No | Number of embedding dimensions: 2 (default) or 3.
|
| alpha | float | No | Transparency of scatter points. Default 0.75.
|
| random_state | int, RandomState, or None | No | Random state for stochastic algorithms. Default None.
|
| colorbar | bool | No | If True and target is continuous, draw a colorbar. Default True.
|
Outputs
| Name | Type | Description |
|---|---|---|
| fit_time_ | Timer | The elapsed time to fit the manifold, displayed in the plot title. |
| classes_ | ndarray, shape (n_classes,) | Class labels (discrete target only). |
| features_ | ndarray, shape (n_features,) | Feature names discovered or provided during fit. |
| Xp (return from transform/fit_transform) | ndarray, shape (n, projection) | The low-dimensional embedding of the input instances. |
| ax | matplotlib Axes | The axes object containing the rendered scatter plot. |
Usage Examples
Basic Usage
from yellowbrick.features import Manifold
from sklearn.datasets import load_iris
X, y = load_iris(return_X_y=True)
visualizer = Manifold(manifold="tsne", random_state=42)
visualizer.fit_transform(X, y)
visualizer.show()
Using Isomap with fit/transform
from yellowbrick.features import Manifold
from sklearn.datasets import load_iris
X, y = load_iris(return_X_y=True)
visualizer = Manifold(manifold="isomap", n_neighbors=10)
visualizer.fit(X, y)
visualizer.transform(X, y)
visualizer.show()
Quick Method
from yellowbrick.features import manifold_embedding
from sklearn.datasets import load_iris
X, y = load_iris(return_X_y=True)
manifold_embedding(X, y, manifold="tsne", random_state=42)