compute_hub_score

compute_hub_score(
    embeddings,
    k=30,
    n_iterations=30,
    neighbors=None,
    similarities=None,
)

Compute hub score for each point in the embedding space.

Hub score identifies structural hub nodes that hold the embedding space together, as opposed to popular instances that fill it. The score combines: - Eigenvector centrality: rewards being in a tightly woven neighborhood - Distance to global centroid: rewards central position in the space

General/structural concepts score high on both signals; specific instances score low on both.

Parameters

Name Type Description Default
embeddings np.ndarray Normalized embeddings (n, d) required
k int Number of neighbors for k-NN graph 30
n_iterations int Iterations for eigenvector power method 30
neighbors Optional[np.ndarray] Pre-computed k-NN indices (n, k+1). If None, computed internally. None
similarities Optional[np.ndarray] Pre-computed similarities (n, k+1). If None, computed internally. None

Returns

Name Type Description
HubScoreResult HubScoreResult with scores and component signals.

Example

result = compute_hub_score(embeddings) hub_nodes = result.get_hub_nodes(threshold=1.0) print(f”Found {len(hub_nodes)} hub nodes”)

Use for taxonomy direction

if result.scores[idx_animal] > result.scores[idx_dog]: … print(“Animal is more general than Dog”)