Orange Forum • View topic - Single Linkage

Single Linkage

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

Single Linkage

Postby henschel » Mon May 30, 2005 12:03

Hi,

I am working with the Hierarchical clustering method and ran in to problems with the single Linkage clustering. The reason might well be that my generated distance matrix does not obey the triangle inequality, however I did not read anything about the requirement of this condition. Average/Complete linkage work all fine.
Code: Select all
from orange import HierarchicalClustering, SymMatrix

if __name__ == "__main__":
    matrix = [[], [14], [0, 0], [30, 0, 0]]  ## C-A = 0, D-C =0 but D-A=30 
    matrix = SymMatrix(matrix)
    root = HierarchicalClustering(matrix, linkage = HierarchicalClustering.Single)

The code above segfaults, and other matrices cause errors like this:

Code: Select all
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/tmp/python-16337a9h.py", line 76, in ?
    clusterList = listifyCluster(root, 10)
  File "/tmp/python-16337a9h.py", line 36, in listifyCluster
    return listifyCluster(cluster.left, cutoff) + \
  File "/tmp/python-16337a9h.py", line 34, in listifyCluster
    return [[el for el in cluster]]
SystemError: internal inconsistency in instance of 'HierarchicalCluster' ('mapping' too short)


Where the listifyCluster simply attempts to produce lists of clusters, given a cutoff:
Code: Select all
def listifyCluster(cluster, cutoff):
    if cluster.height < cutoff:
        return [[el for el in cluster]]
    else:
        return listifyCluster(cluster.left, cutoff) + \
               listifyCluster(cluster.right, cutoff)


Do I have to provide better matrices or is there another way? Many thanks!

Andreas

Postby Janez » Fri Jun 03, 2005 21:51

No, it's not the triangle inequality, it's a bug. I have it on the list for a long time already, now it's time to fix it.

Postby henschel » Mon Jun 20, 2005 16:29

Thanks, that would be great! When/how do I get to know about the bugfix being done?

Postby Janez » Wed Jul 13, 2005 22:23

I guess I have fixed it. It only crashed on some data sets; now I tried it on quite a few and it works.

This night's snapshot should work. Please tell me if you still have any problems.


Return to Questions & Support



cron