UMAP (Uniform Manifold Approximation and Projection) is a general-purpose manifold learning and dimensionality reduction algorithm. It constructs a high-dimensional graph and then searches for a low-dimensional projection of the data that has the closest possible equivalent fuzzy topological structure. The current version is 0.5.12, with a release cadence that includes frequent patch releases and minor updates.
pip install umap-learnVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `umap-learn` to reduce the dimensionality of a synthetic dataset. It covers generating data, initializing the `UMAP` reducer with common parameters, and performing the fit and transform operation.
Always pass an integer value to the `random_state` parameter during `UMAP` object initialization, e.g., `umap.UMAP(random_state=42)`.
Experiment with different values for `n_neighbors` (e.g., 5 to 50) and `min_dist` (e.g., 0.0 to 0.5). Higher `n_neighbors` captures more global structure, while lower `min_dist` allows for tighter clustering.
Understand that `transform` is an approximation. If exact embeddings for new data are critical, consider retraining UMAP on the combined dataset or evaluating the stability of the transformation for your application. For small changes to the dataset, `update` might be an option.
Ensure `numba` is correctly installed and compatible with your Python environment. Check for any `numba` warnings upon import or during execution. Refer to the `numba` documentation for troubleshooting installation issues.
It is generally recommended to preprocess data by scaling or normalizing features before applying UMAP, e.g., using `sklearn.preprocessing.StandardScaler` or `MinMaxScaler`.
Install the library using pip: `pip install umap-learn`
Reduce the value of `n_neighbors` to be strictly less than the number of samples in your dataset (e.g., `n_neighbors=min(your_value, X.shape[0] - 1)`).
Install `umap-learn` with its accelerate extras: `pip install umap-learn[accelerate]` or specifically install `pynndescent`: `pip install pynndescent`
Ensure that if `metric='precomputed'`, `X` is a precomputed distance matrix and no other `metric` argument is passed, or ensure the metric is set to 'precomputed' when using a precomputed matrix.