fix: pass annual-only windows to compute_nd_axes in SVD components tab
_get_aligned_party_scores and _get_aligned_trajectory_scores both called compute_nd_axes() with no window_ids, which defaulted to _load_window_ids() returning ALL windows including quarterly. This caused the SVD component 1 bar chart to disagree with the compass (which correctly used annual-only windows via get_uniform_dim_windows). D66 appeared between GL-PvdA and PvdD in component 1 because quarterly windows contaminated the PCA basis.
This commit is contained in:
+8
-3
@@ -633,8 +633,10 @@ def _get_aligned_trajectory_scores(
|
||||
"""
|
||||
from analysis.political_axis import compute_nd_axes
|
||||
|
||||
# Get aligned scores for all windows via PCA
|
||||
scores_by_window, _ = compute_nd_axes(db_path, n_components=n_components)
|
||||
# Get aligned scores for the requested windows via PCA (annual-only, no quarterly)
|
||||
scores_by_window, _ = compute_nd_axes(
|
||||
db_path, window_ids=windows, n_components=n_components
|
||||
)
|
||||
if not scores_by_window:
|
||||
return {}
|
||||
|
||||
@@ -2634,7 +2636,10 @@ def build_svd_components_tab(db_path: str) -> None:
|
||||
"""Get party scores for all N components from aligned PCA positions."""
|
||||
from analysis.political_axis import compute_nd_axes
|
||||
|
||||
scores_by_window, _ = compute_nd_axes(db_path, n_components=10)
|
||||
annual_windows = get_uniform_dim_windows(db_path)
|
||||
scores_by_window, _ = compute_nd_axes(
|
||||
db_path, window_ids=annual_windows, n_components=10
|
||||
)
|
||||
window_scores = scores_by_window.get(window, {})
|
||||
if not window_scores:
|
||||
return {}
|
||||
|
||||
Reference in New Issue
Block a user