How do you assign new, unseen data points to clusters produced by DBSCAN or agglomerative clustering?

Last updated 11 November 2026

  • Neither algorithm has a native predict() (only fit_predict), because clusters are defined by the training points themselves. Re-fitting with new data can change existing labels.

  • Mimic the algorithm's own rule: for DBSCAN, assign the nearest core sample's label if within eps, else noise (-1). For agglomerative, use nearest neighbor or nearest centroid with a distance threshold. HDBSCAN offers approximate_predict.

  • General alternative: train a surrogate classifier (k-NN, random forest) on features and cluster labels. Always reuse the training-fitted preprocessing, and re-cluster if many new points fall far from clusters (drift).

  • https://scikit-learn.org/stable/modules/clustering.html
  • https://medium.com/@arko_sengupta/dbscan-a-comprehensive-guide-73f236632d60
  • https://www.meritshot.com/tutorials/machine-learning/hierarchical-and-dbscan-clustering
All Clustering interview questions