1
$\begingroup$

First a theoretical question. I know that natively, an hierarchical clustering algorithm is of complexity on the cube of number of samples N. This is due to the fact that in each iteration, one has to go over the entire distance matrix to find the smallest value.

But, it is possible to implement it in lower complexity (of N square). How it is done and can you refer me to an article or description of the implementation?

Finally, I used scikit library to do HClustering. It was fine but it is limited to 15,000 samples or so. I want to cluster much more. can someone refer me to an implementation that fits larger numbers (and preferably runs at square root N)?

$\endgroup$
  • $\begingroup$ Most "good" implementations start with the whole matrix and diminish it by 1 row and column at each step. This is efficient if the language is quick in cutting array portions. $\endgroup$ – ttnphns Dec 18 '13 at 12:40
  • $\begingroup$ But what is dubious is your intention to do hierarchical clustering of too many objects. Not because of speed/memory. If you are hoping to cluster thousands of objects in few clusters (as usual) you must be aware that risk/amount of suboptimality goes up with steps. So, last steps in hierarchical clustering of big data are likely to be relatively much worse than last steps with small data. This is the reason why classic hierarchical cluastering algorithm is not recommended for big data anyway. $\endgroup$ – ttnphns Dec 18 '13 at 12:53
  • $\begingroup$ "Diminishing" will not take you to N^2. I don't think this is the optimization done.. regarding your second comment, Im planning on calculating the thd on a small data, and setting it on big/large scale data. My output will be (hopefully, for my needs) 99% singlton clusters and only a very very small amount of clusters containing more then one sample in it. $\endgroup$ – idoda Dec 18 '13 at 14:14
  • $\begingroup$ @ttnphns I doubt that a matrix-based approach can get down to $O(n^2)$. See: most matrix operations (such as searching the maximum) need $O(n^2)$, and if you do these at each iteration, you will be in $O(n^3)$. Methods such as SLINK that work in $O(n^2)$ do also need only linear memory! $\endgroup$ – Anony-Mousse Dec 21 '13 at 21:49
  • $\begingroup$ @Anony-Mousse, my first comment said nothing about O(n^2); it was just a comment. I feel like agreeing with your answer below; I too, tend to think that it is possible only with single and complete linkages. $\endgroup$ – ttnphns Dec 21 '13 at 21:55
3
$\begingroup$

As far as I know, this is not generally possible, but algorithms only exist for particular linkages; i.e. SLINK for single-link and CLINK for complete-link.

ELKI includes an $O(n^2)$ implementation, i.e. SLINK.

If I understood SLINK correctly, it essentially works "one row at a time", which is why it also needs less (linear!) memory.

$\endgroup$
  • $\begingroup$ Thanks! I'm reading the SLINK documentation right now, and that is what i needed. $\endgroup$ – idoda Dec 22 '13 at 11:22
0
$\begingroup$

This is simply to answer the last part of your question (cannot run HClustering on more than 15,000 samples).

If you really want to do a hierarchical clustering (for interpretation), I would suggest running kmeans (that will run quite fast with scikit) with a high k-value (for example 1000 or 100). Then, you run the HClustering on the resulting centroids to have a global clustering. (and you can reassign each point to its centroid and then to its cluster).

$\endgroup$
  • $\begingroup$ mmm.. I wonder whether this would work.. still, I'm sure there are Hclustring algorithms that are better implemented then the one scikit is implementing. $\endgroup$ – idoda Dec 18 '13 at 14:42
  • $\begingroup$ yes this would work. It's called 2-steps clustering. $\endgroup$ – Scratch Dec 18 '13 at 14:48
  • $\begingroup$ Well, for me, this is not possible. I cant do K-Means on my data, all I have (and all i can generate) is an observation2observation distance, but i cant calculate distance to an arbitrary reference point. $\endgroup$ – idoda Dec 22 '13 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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