|
|
|
@ -133,6 +133,7 @@ def compute_2d_axes( |
|
|
|
window_ids: Optional[List[str]] = None, |
|
|
|
window_ids: Optional[List[str]] = None, |
|
|
|
method: str = "pca", |
|
|
|
method: str = "pca", |
|
|
|
anchor_kwargs: Optional[Dict] = None, |
|
|
|
anchor_kwargs: Optional[Dict] = None, |
|
|
|
|
|
|
|
normalize_vectors: bool = True, |
|
|
|
) -> Tuple[Dict[str, Dict[str, Tuple[float, float]]], Dict[str, np.ndarray]]: |
|
|
|
) -> Tuple[Dict[str, Dict[str, Tuple[float, float]]], Dict[str, np.ndarray]]: |
|
|
|
"""Compute 2D coordinates for MPs per window. |
|
|
|
"""Compute 2D coordinates for MPs per window. |
|
|
|
|
|
|
|
|
|
|
|
@ -174,7 +175,11 @@ def compute_2d_axes( |
|
|
|
entity_index = [] # parallel list of (window_id, entity) |
|
|
|
entity_index = [] # parallel list of (window_id, entity) |
|
|
|
for wid, d in aligned_window_vecs.items(): |
|
|
|
for wid, d in aligned_window_vecs.items(): |
|
|
|
for ent, v in d.items(): |
|
|
|
for ent, v in d.items(): |
|
|
|
all_vecs.append(v) |
|
|
|
if normalize_vectors: |
|
|
|
|
|
|
|
n = np.linalg.norm(v) |
|
|
|
|
|
|
|
all_vecs.append(v / n if n > 1e-10 else v) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
all_vecs.append(v) |
|
|
|
entity_index.append((wid, ent)) |
|
|
|
entity_index.append((wid, ent)) |
|
|
|
|
|
|
|
|
|
|
|
if len(all_vecs) == 0: |
|
|
|
if len(all_vecs) == 0: |
|
|
|
|