Spaces:
Runtime error
Runtime error
Update clustering.py
Browse files- clustering.py +6 -5
clustering.py
CHANGED
@@ -706,18 +706,19 @@ def build_sankey_data(
|
|
706 |
values = []
|
707 |
comments = []
|
708 |
|
709 |
-
|
710 |
-
log_message(f"build_sankey_data {
|
711 |
valid_clusters = {}
|
712 |
|
713 |
-
for threshold in
|
|
|
714 |
valid_clusters[threshold] = [
|
715 |
j
|
716 |
for j in np.unique(cluster_assignments[threshold])
|
717 |
if cluster_counts[threshold].get(j, 0) >= min_items_by_cluster
|
718 |
]
|
719 |
|
720 |
-
for i, threshold in enumerate(
|
721 |
for j in valid_clusters[threshold]:
|
722 |
cluster_name = (
|
723 |
f"{j} (d={threshold})\nTotal: {cluster_counts[threshold].get(j, 0)}"
|
@@ -733,7 +734,7 @@ def build_sankey_data(
|
|
733 |
)
|
734 |
|
735 |
if i > 0:
|
736 |
-
prev_threshold =
|
737 |
for prev_cluster in valid_clusters[prev_threshold]:
|
738 |
for curr_cluster in valid_clusters[threshold]:
|
739 |
count = np.sum(
|
|
|
706 |
values = []
|
707 |
comments = []
|
708 |
|
709 |
+
sorted_threshold_values = sorted(cluster_assignments.keys())
|
710 |
+
log_message(f"build_sankey_data {sorted_threshold_values}")
|
711 |
valid_clusters = {}
|
712 |
|
713 |
+
for threshold in sorted_threshold_values:
|
714 |
+
print(threshold)
|
715 |
valid_clusters[threshold] = [
|
716 |
j
|
717 |
for j in np.unique(cluster_assignments[threshold])
|
718 |
if cluster_counts[threshold].get(j, 0) >= min_items_by_cluster
|
719 |
]
|
720 |
|
721 |
+
for i, threshold in enumerate(sorted_threshold_values):
|
722 |
for j in valid_clusters[threshold]:
|
723 |
cluster_name = (
|
724 |
f"{j} (d={threshold})\nTotal: {cluster_counts[threshold].get(j, 0)}"
|
|
|
734 |
)
|
735 |
|
736 |
if i > 0:
|
737 |
+
prev_threshold = sorted_threshold_values[i - 1]
|
738 |
for prev_cluster in valid_clusters[prev_threshold]:
|
739 |
for curr_cluster in valid_clusters[threshold]:
|
740 |
count = np.sum(
|