Commit 687e2fc1 authored by Alexander Lercher's avatar Alexander Lercher

[RoleStage] Improved clustering performance

parent e9d9abe1
......@@ -59,9 +59,14 @@ class Clusterer:
def group_by_clusters(self, dataset:List[Dict], labels:List[Any]) -> Dict[Any, List[Dict]]:
clusters = {}
# TODO optimize by iterating through dataset only once
for label in labels:
clusters[label] = [ds for ds in dataset if ds['cluster_label'] == label]
for ds in dataset:
label = ds['cluster_label']
if label not in clusters:
clusters[label] = []
clusters[label].append(ds)
return clusters
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment