Orange Forum • View topic - Hierarchical Clustering and Height Distance

Hierarchical Clustering and Height Distance

A place to ask questions about methods in Orange and how they are used and other general support.

Hierarchical Clustering and Height Distance

Postby re832003 » Tue Sep 17, 2013 12:06

Is There a way to print out the height distances of each leaf in the heirarchical clustering tree, preferably in a sorted order?

Thanks,
Rania

Re: Hierarchical Clustering and Height Distance

Postby Ales » Wed Sep 18, 2013 11:22

Code: Select all
# root is the root HierarchicalCluster instance
clusters = Orange.clustering.hierarchical.cluster_to_list(root)
leaf_heights = []
for cluster in clusters:
    for branch in cluster.branches or []:
        if not branch.branches:
            # branch is a leaf
            leaf_heights.append((cluster.height, branch))

print sorted(leaf_heights)

Also see the reference for Orange.clustering.hierarchical


Return to Questions & Support