How would you approach clustering a dataset of hundreds of millions of points?
Role: Machine Learning Engineer
Category: Machine Learning
Difficulty: hard
Interview Round: Other
How would you approach clustering a dataset of hundreds of millions of points?
```hint Do the arithmetic first
Estimate what a step that compares every pair of points would cost at a few hundred million points before you pick an algorithm.
```
```hint Not every step needs every point
Ask which parts of the job have to touch all of the data and which could run on a subset or on a compressed copy.
```
### Constraints & Assumptions
- The dataset has hundreds of millions of points.
- Dimensionality, the expected number of clusters and the available hardware are not given. State what you assume.
### Clarifying Questions to Ask
- What is the clustering for: customer segmentation, deduplication, or building a vector index?
- How many dimensions does each point have, and are the features dense embeddings or tabular columns?
- Roughly how many clusters do you expect, and can they be roughly spherical, or do you need arbitrary shapes with noise points?
- Is this a one-off batch job, or must clusters refresh as new points arrive, and how fast?
- What compute is available: one machine with a GPU, or a distributed cluster such as Spark?
### What a Strong Answer Covers
- Scoping questions that change the choice of algorithm
- Why methods that need pairwise distances are ruled out at this size, backed by a rough cost estimate
- Ways to shrink the problem, such as sampling, dimensionality reduction and compression
- Scalable algorithms or execution models (mini-batch, one-pass summaries, GPU, distributed) and what each gives up
- How to validate and maintain the clusters without full-data quadratic metrics
### Follow-up Questions
- How would you choose the number of clusters when a full silhouette or elbow curve is too expensive?
- The clusters must refresh daily as new points arrive. How do you keep cluster IDs stable from one run to the next?
- If you fit on a uniform sample, how do you avoid losing small but important clusters?
- What changes if the points are high-dimensional text embeddings and the real goal is an approximate nearest neighbor index?
Overview: Asks how to cluster a dataset with hundreds of millions of points when memory and compute limit which algorithms are possible. Tests scaling judgment: algorithm complexity, sampling and compression, streaming or distributed execution, and how to validate clusters at this size.