Course contentsShow
← Machine Learning and Deep Learning
Lesson 402 of 3,5389. Dimensionality ReductionFree lesson

UMAP: Hyperparameters and Their Effects

How n_neighbors, min_dist, and metric choice affect the embedding structure and when to adjust them.

UMAP: Hyperparameters and Their Effects

What You'll Learn

You'll understand how UMAP's three key hyperparameters shape your embedding and when to adjust them for different data exploration goals.

The Three Control Knobs

UMAP gives you three main dials to tune how it builds your low-dimensional representation:

n_neighbors: Local vs Global Structure

Think of n_neighbors as setting how nearsighted UMAP is when examining your data. With low values (5-15), UMAP focuses on very local patterns—great for finding fine-grained cluster structure. With high values (50-200), it captures broader relationships and preserves more global structure, but may blur smaller clusters together.

When to adjust: Use lower values when you suspect many small, distinct groups. Increase it when you care more about overall data topology than tiny subdivisions.

min_dist: Tightness of Clusters

This controls how tightly UMAP packs points together in the embedding. Low values (0.0-0.1) create tight, distinct clumps—excellent for visualization and cluster separation. Higher values (0.3-0.99) spread points out more evenly, preserving more continuous structure.

When to adjust: Lower it for cleaner cluster visualization. Raise it when relationships between clusters matter more than separation, or when avoiding overlapping points isn't critical.

metric: How Distance is Measured

The distance function (euclidean, cosine, manhattan, etc.) determines what "similar" means. Euclidean works for general numerical data. Cosine is better for high-dimensional vectors where direction matters more than magnitude (like text embeddings).

When to adjust: Match your metric to your data type—use cosine for normalized features or angular relationships, manhattan for grid-like data.

Key Takeaway: n_neighbors controls local-global balance, min_dist controls cluster tightness, and metric defines similarity—tune them based on whether you prioritize local detail, visual separation, or data-specific distance semantics.