What does the n_neighbors parameter control in UMAP?

Quick Overview

Asks what the n_neighbors parameter controls in UMAP and how changing it alters an embedding. It tests understanding of the neighborhood graph UMAP builds, the trade-off between local detail and global structure, and how to tune the value sensibly.

What does the n_neighbors parameter control in UMAP?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

What does the `n_neighbors` parameter control in UMAP? Assume you are using UMAP to produce a two-dimensional embedding of a high-dimensional dataset for visualization. ```hint Start from the graph UMAP builds a graph in the original space before it optimizes anything. Think about what happens to that graph as each point looks at more or fewer neighbors. ``` ### What a Strong Answer Covers - Its role in building the k-nearest-neighbor graph and in setting each point's distance scale - What small values do to the embedding, including the risk of fragmented clusters - What large values do, including the loss of fine detail and the extra runtime - Practical tuning: the default value, sweeping several values, and the analogy with t-SNE perplexity ### Follow-up Questions - How does `min_dist` differ from `n_neighbors` in what it controls? - Why should you be careful reading distances between clusters in a UMAP plot? - How would you set `n_neighbors` when UMAP is a preprocessing step for clustering instead of a plot?

Overview: Asks what the n_neighbors parameter controls in UMAP and how changing it alters an embedding. It tests understanding of the neighborhood graph UMAP builds, the trade-off between local detail and global structure, and how to tune the value sensibly.

General logo
General
Nov 25, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

What does the n_neighbors parameter control in UMAP?

Assume you are using UMAP to produce a two-dimensional embedding of a high-dimensional dataset for visualization.

What a Strong Answer Covers Guidance

  • Its role in building the k-nearest-neighbor graph and in setting each point's distance scale
  • What small values do to the embedding, including the risk of fragmented clusters
  • What large values do, including the loss of fine detail and the extra runtime
  • Practical tuning: the default value, sweeping several values, and the analogy with t-SNE perplexity

Follow-up Questions Guidance

  • How does min_dist differ from n_neighbors in what it controls?
  • Why should you be careful reading distances between clusters in a UMAP plot?
  • How would you set n_neighbors when UMAP is a preprocessing step for clustering instead of a plot?