I have a set of documents and distances among them. I want to cluster the documents based on pairwise distances/similarities among them.

I have only a single parameter as distance. What are the available clustering algorithms to work on these kind of problems?

  • $\begingroup$ Please clarify what you mean by "correlation distance". $\endgroup$ Commented Mar 18, 2019 at 9:36
  • $\begingroup$ correlation distances means distance between every two nodes. $\endgroup$
    – Rajeev
    Commented Mar 18, 2019 at 10:20

1 Answer 1


Assuming that you only have access to pairwise distances among your documents but no access to the documents themselves, there are still some clustering techniques you can apply.

Algorithms like k-Means, which require access to the feature space (e.g., to place the centroids) cannot be applied. However, scikit-learn has some other clustering algorithms which can work by simply analyzing a matrix of pairwise distances among samples:

edit: Take a look at the concerns of @Anony-Mousse in the comments to this answer.

  • 1
    $\begingroup$ Note that affinity requires different input than distance metrics. $\endgroup$ Commented Mar 18, 2019 at 19:18
  • $\begingroup$ @Anony-Mousse, can you be more specific? I can edit the answer if I am missing something. $\endgroup$ Commented Mar 19, 2019 at 9:11
  • 1
    $\begingroup$ Some methods require a similarity, some a distance. That is not the same. $\endgroup$ Commented Mar 19, 2019 at 17:24
  • $\begingroup$ Well, I checked and all the cited clustering methods from sklearn accept euclidean distances. I will remove the "or some other similarity measure" from the answer, as maybe some weird custom similarities might cause problems with some of the algorithms. Thanks for the correction. $\endgroup$ Commented Mar 19, 2019 at 21:38
  • $\begingroup$ Try passing a precomputed Euclidean distance matrix to these functions vs. passing the data matrix and setting the parameter to run euclidean. You'll see that for the first two you get fundamentally different results, only the bottom two expect a distance matrix k (to make it more confusing, the "affinity" parameter of AC does not expect an affinity but a distance matrix). $\endgroup$ Commented Mar 19, 2019 at 22:19

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.