About this project
UMAP (Uniform Manifold Approximation and Projection) is a dimension reduction technique for visualization and general nonlinear embedding, implemented as the Python package umap-learn. It is designed to work like a scikit-learn transformer, so it can be used as a drop-in alternative to t-SNE in existing pipelines.
The method is based on three assumptions: data is uniformly distributed on a Riemannian manifold, the Riemannian metric is locally constant, and the manifold is locally connected. These assumptions are used to build a fuzzy topological representation, and the embedding is found by searching for a low-dimensional projection with the closest equivalent structure. The mathematics is described in the ArXiv paper 1802.03426, with a broader introduction in a Nature Reviews Methods Primers article.
Installation is available through conda-forge (conda install -c conda-forge umap-learn) or PyPI (pip install umap-learn). It depends on scikit-learn, numpy, scipy, numba, tqdm, and pynndescent. Optional extras cover plotting (matplotlib, datashader, holoviews), Parametric UMAP (TensorFlow), and tbb CPU optimizations on x86.
Basic usage mirrors scikit-learn:
import umap
from sklearn.datasets import load_digits
digits = load_digits()
embedding = umap.UMAP().fit_transform(digits.data)
Key parameters include n_neighbors, which controls how much local versus global structure is preserved (commonly 5-50, with 10-15 a sensible default), min_dist, which controls how tightly points are packed (0.001-0.5, with 0.1 a reasonable default), and metric, which selects the distance function in input space. Sparse matrix input is supported.
Documented benefits include speed on large and high-dimensional datasets, scaling in embedding dimension for general preprocessing, preservation of some global structure, support for non-metric distances such as cosine and correlation, the ability to add new points to an existing embedding via transform, and supervised or semi-supervised reduction by passing labels as y. Experimental features include inverse transform, non-Euclidean embeddings such as hyperbolic embeddings, embeddings with uncertainty, and preliminary dataframe support.
The package also provides densMAP, enabled with densmap=True, which augments UMAP to preserve local density information. densMAP adds parameters such as dens_frac, dens_lambda, dens_var_shift, and output_dens, and recommends larger n_neighbors values (e.g. 30). Parametric UMAP trains a neural network to learn a UMAP-based transformation, supporting faster inference on unseen data, more robust inverse transforms, autoencoder variants, and semi-supervised classification. A umap.plot subpackage offers basic and interactive plotting with hover tools and diagnostic options.
For GPU acceleration, the README points to torchdr, a PyTorch-based implementation that accelerates kNN computation, affinity construction, and embedding optimization on GPU.
Documentation is hosted on Read the Docs, including a FAQ. The project is 3-clause BSD licensed and welcomes contributions. The README asks users to cite the JOSS software paper, the ArXiv paper, and, where applicable, the densMAP, Parametric UMAP, and Nature Primer references.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.