Check python-cluster
Using this library, you can do something like this:
from cluster import * data = [10.01,5.001,4.89,5.1,9.9,10.1,5.05,4.99] cl = HierarchicalClustering(data, lambda x,y: abs(xy)) print [mean(cluster) for cluster in cl.getlevel(1.0)]
And you will get:
[5.0062, 10.003333333333332]
(This is a very stupid example, because I really do not know what you want to do, and because this is the first time I used this library)
source share