# How to compute the number of centroids for K-means clustering algorithm given minimal distance?

I need to cluster my points into unknown number of clusters, given the minimal Euclidean distance R between the two clusters. Any two clusters that are closer than this minimal distance should be merged and treated as one.

I could implement a loop starting from the two clusters and going up until I observe the pair of clusters that are closer to each other than my minimal distance. The upper boundary of the loop is the number of points we need to cluster.

Are there any well known algorithms and approaches estimate the approximate number of centroids from the set of points and required minimal distance between centroids?

I am currently using FAISS under Python, but with the right idea I could also implement in C myself.

Yes, the silhouette method (which is implemented in sklearn as silhouette_score) is commonly used to assess the quality of clusters produced by any clustering algorithm (including $$k$$-means or any hierarchical clustering algorithm). Roughly, you can compute the silhouette value for different $$k$$, then you would pick the $$k$$ with the highest silhouette value.