lbehnke / hierarchical-clustering-java

Implementation of an agglomerative hierarchical clustering algorithm in Java. Different linkage approaches are supported.
141 stars 79 forks source link

How to set number of clusters #16

Closed adnanakhter closed 8 years ago

adnanakhter commented 8 years ago

Dear Reader, I am trying to implement agglomerative algo in our project. However in my case i need to set number of clusters in the beginning.. I know that the algorithm repeats until it makes all points in a single cluster, this means we need to cut the dendrogram at some point to get our desired number of clusters. Could anyone help in this? Thanks

lbehnke commented 8 years ago

I am not sure what you intent to achieve. If you want to restrict the number of cluster nodes, you could do so by post-processing the cluster result. For example you could group the leaf nodes until you reach the your tree size limit.

emanlee commented 4 years ago

Here is a figure on this home page: https://github.com/lbehnke/hierarchical-clustering-java. From this dendrogram, how can we get clusters or groups. For example, if we want get two clusters, it should be [o6] [o1 o2 o3 o4 o5]; If we want get three clusters, it should be [06] [03 05] [01 02 04 ]. How to use codes to get such clusters and output them to console or files? Thanks!

emanlee commented 4 years ago

In my case, I have more than 800 samples/genes. After clustering, the dendrogram is very big and complex, therfore, we need to divide/cut/sect the dendrogram into clusters and save them to files (each file contains the gene names and represents a cluster/group).