I want to perform DBSCAN on my datapoints, but I don't have access to the data, I just have the pairwise distance of datapoints. Additionally, I have no idea about the number of clusters but I do want that each cluster contains at least 40 data points. Does DBSCAN work with these conditions? For instance, can I have something like this? Or is more information needed? I want to emphasize that I have computed the pairwise distance and this is not the result of Euclidean or some other method.

from sklearn.cluster import DBSCAN

db = DBSCAN(min_samples=40, metric="precomputed")

y_db = db.fit_predict(my_pairwise_distance_matrix)

I am not sure what is eps parameter of DBSCAN(). How should I set that?


1 Answer 1


DBSCAN does not guarantee a minimum cluster size. There are known situations, c.f. Wikipedia, where a cluster can have fewer than "minPts" points. Furthermore, it has the concept of noise: points that do not have enough neighbors.

For epsilon, also see the Wikipedia article. As you don't specify the number of clusters, this parameter is what mostly controls how many clusters you get. Set it to 0, and everything will be noise. Set it to the maximum distance, and everything will be in one cluster.

Really read the article. It's about density, not about cluster sizes.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.