# HG changeset patch # User Nicolas Saunier # Date 1439588745 14400 # Node ID 2472b4d59aea65b81857ac3750b24aa807fe4714 # Parent fb60b54e1041b2126d99afccb3e0070088d37ea1 small function diff -r fb60b54e1041 -r 2472b4d59aea python/ml.py --- a/python/ml.py Fri Aug 14 11:29:02 2015 -0400 +++ b/python/ml.py Fri Aug 14 17:45:45 2015 -0400 @@ -176,3 +176,8 @@ indices.append(smallestClusterIndex) return prototypeIndices, labels + +def computeClusterSizes(labels, prototypeIndices, outlierIndex = -1): + clusterSizes = {i: sum(np.array(labels) == i) for i in prototypeIndices} + clusterSizes['outlier'] = sum(np.array(labels) == -1) + return clusterSizes