qbiocode.apps.quvine.evaluation.ranking module#

Summary#

Classes:

SeedTargetEvaluator

Evaluates seed→target prioritization on a subgraph.

Functions:

evaluate_embeddings_ranking

Score every method's node ranking against the target set.

l2_normalize

max_seed_cosine_scores

Returns scores[v] = max_{s in seeds} cosine(z_v, z_s) Works for any embedding Z.

seed_centroid_scores

Generates centroid scores based on seed node embeddings.

Reference#

class SeedTargetEvaluator(subgraph, seeds, targets, nodes=None)[source]#

Bases: object

Evaluates seed→target prioritization on a subgraph.

recall_at_k(scores, target_indices, k)[source]#
precision_at_k(scores, target_indices, k)[source]#
degree_matched_targets(tolerance=0.1, random_state=None)[source]#
distance_matched_targets(random_state=None)[source]#
evaluate(scores, k_values=[20, 50, 100], n_repeats=20, deg_tol=0.1)[source]#
evaluate_embeddings_ranking(scores_by_method, subgraph, seeds, targets, nodes, k_values=[30, 60, 90, 120], n_repeats=30, deg_tol=0.1, iteration=None)[source]#

Score every method’s node ranking against the target set.

Parameters:

scores_by_method (Dict[str, np.ndarray]) – Mapping from method name to node-level score vector.

Returns:

One tidy row per method, k value and repeat.

Return type:

pd.DataFrame

l2_normalize(X, axis=1, eps=1e-12)[source]#
seed_centroid_scores(Z, seed_indices)[source]#

Generates centroid scores based on seed node embeddings.

Z: (n,e) embedding matrix aligned with subgraph nodes seed_indices: list of indices corresponding to seed nodes in Z

Returns:

scores

Return type:

cosine similarity to seed centroid

max_seed_cosine_scores(Z, seed_indices, block=4096)[source]#

Returns scores[v] = max_{s in seeds} cosine(z_v, z_s) Works for any embedding Z.

block: compute in chunks to reduce memory if needed.