feat: auto-compute flip directions for all SVD components (Task 6)
This commit is contained in:
+13
@@ -2877,6 +2877,19 @@ def build_svd_components_tab(db_path: str) -> None:
|
||||
{p: len(v) for p, v in party_mp_vectors.items()} if party_mp_vectors else {}
|
||||
)
|
||||
|
||||
# Auto-compute flip directions for all components based on party centroids
|
||||
# This ensures right-wing parties consistently appear on the right side
|
||||
try:
|
||||
from analysis.svd_labels import compute_flip_direction
|
||||
|
||||
for comp in range(1, 11):
|
||||
flip = compute_flip_direction(comp, party_scores)
|
||||
if comp in SVD_THEMES:
|
||||
SVD_THEMES[comp]["flip"] = flip
|
||||
except Exception:
|
||||
# If flip computation fails, keep existing flip values in SVD_THEMES
|
||||
pass
|
||||
|
||||
# Convert party_scores (possibly [x,y] lists or legacy vectors) into explicit (x,y) coords
|
||||
party_coords: dict = {}
|
||||
for p, v in party_scores.items():
|
||||
|
||||
Reference in New Issue
Block a user