How do you assign new, unseen data points to clusters produced by DBSCAN or agglomerative clustering?
Role: Machine Learning Engineer
Category: Machine Learning
Difficulty: medium
Interview Round: Other
You clustered a dataset with DBSCAN or with agglomerative (hierarchical) clustering, and new points keep arriving after the fit. How do you assign new, unseen data points to clusters produced by DBSCAN or agglomerative clustering?
```hint What defines a cluster
Ask what each algorithm keeps after fitting: a model of the space, such as centroids or a density estimate, or only the training points and their labels.
```
```hint Reuse the algorithm's own rule
For DBSCAN, think about which kind of training point is allowed to pull a neighbor into its cluster. For agglomerative clustering, think about what the linkage measures.
```
### What a Strong Answer Covers
- Why these algorithms have no `predict` method, and why refitting on old plus new data is a poor substitute.
- An assignment rule for DBSCAN that is consistent with its core, border and noise definitions.
- Assignment rules for agglomerative clustering that match the linkage used, with a way to leave far-away points unassigned.
- A general alternative that works for any clustering, and how to check it.
- Operational details: identical preprocessing and watching for drift.
### Follow-up Questions
- A new point is within `eps` of core points from two different clusters. What should happen, and what does DBSCAN itself do with such points during the fit?
- What if enough new points arrive in one empty region to form a dense cluster of their own?
- How would you choose the distance threshold for leaving a point unassigned in agglomerative clustering?
- When you eventually re-cluster, how do you keep cluster IDs stable for downstream users?
Overview: Asks how to label new data points after clustering with DBSCAN or agglomerative clustering, neither of which has a predict method. Tests understanding of how each algorithm defines its clusters, how to reproduce its assignment rule, and how to handle outliers, preprocessing and drift in production.