diff python/ml.py @ 738:2472b4d59aea dev

small function
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 14 Aug 2015 17:45:45 -0400
parents 0e875a7f5759
children 1f2b2d1f4fbf
line wrap: on
line diff
--- 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