changeset 738:2472b4d59aea dev

small function
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Fri, 14 Aug 2015 17:45:45 -0400
parents fb60b54e1041
children 25e78d756823
files python/ml.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
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