How do you assign new, unseen data points to clusters produced by DBSCAN or agglomerative clustering?
Last updated
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 offersapproximate_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).