qbiocode.apps.quvine.reproducibility.method_adapters module#
Method Adapters for Reproducible Benchmarking Pipeline
This module provides adapter functions that wrap all 42 QuVINE methods to work with the reproducible pipeline interface.
Each adapter: 1. Accepts pre-generated graph and split 2. Uses the provided canonical seed 3. Returns standardized metrics 4. Does NOT modify input data or create its own splits
Summary#
Functions:
Evaluate link prediction using dot product similarity. |
|
Evaluate node ranking task. |
|
Generate quantum walk targets for filter calibration. |
|
Get the adapter function for a method. |
|
Adapter for APPNP method. |
|
Adapter for generic baseline filter (defaults to heat kernel). |
|
Adapter for baseline heat kernel filter (no quantum calibration). |
|
Adapter for baseline polynomial filter (no quantum calibration). |
|
Adapter for baseline GCN-MF (no quantum calibration). |
|
Fusion method combining CTQW-based embeddings. |
|
Fusion method combining DTQW-based embeddings. |
|
Adapter for CTQW + heat kernel filter. |
|
Adapter for CTQW + polynomial filter. |
|
Adapter for RWR + heat kernel filter. |
|
Adapter for RWR + polynomial filter. |
|
Generic GAT adapter that handles all 12 GAT variants. |
|
GAT with raw structural features. |
|
GAT with direct CTQW features. |
|
GAT with CTQW-calibrated heat kernel features. |
|
GAT with CTQW-calibrated polynomial features. |
|
GAT with direct DTQW features. |
|
GAT with DTQW-calibrated heat kernel features. |
|
GAT with DTQW-calibrated polynomial features. |
|
GAT with fixed heat kernel features. |
|
GAT with fixed polynomial features. |
|
GAT with RWR walk features. |
|
GAT with RWR-calibrated heat kernel features. |
|
GAT with RWR-calibrated polynomial features. |
|
Generic GraphGPS adapter that handles all 12 GraphGPS variants. |
|
GraphGPS with raw structural features. |
|
GraphGPS with direct CTQW features. |
|
GraphGPS with CTQW-calibrated heat kernel features. |
|
GraphGPS with CTQW-calibrated polynomial features. |
|
GraphGPS with direct DTQW features. |
|
GraphGPS with DTQW-calibrated heat kernel features. |
|
GraphGPS with DTQW-calibrated polynomial features. |
|
GraphGPS with fixed heat kernel features. |
|
GraphGPS with fixed polynomial features. |
|
GraphGPS with RWR walk features. |
|
GraphGPS with RWR-calibrated heat kernel features. |
|
GraphGPS with RWR-calibrated polynomial features. |
|
Adapter for GraphSAGE method. |
|
Adapter for NetMF method. |
|
Adapter for Node2Vec method. |
|
Adapter for QuVINE CTQW (Continuous-Time Quantum Walk + SGNS). |
|
Adapter for QuVINE DTQW (Discrete-Time Quantum Walk + SGNS). |
|
Adapter for QuVINE RWR (Random Walk with Restart + SGNS). |
|
Run QuVINE SGNS embedding with specified walk type. |
|
Fusion method combining RWR-based embeddings. |
|
Train a logistic regression classifier on embeddings. |
Reference#
- train_classifier(embeddings, train_idx, val_idx, test_idx, labels, seed)[source]#
Train a logistic regression classifier on embeddings.
- Parameters:
embeddings (np.ndarray) – Node embeddings [N, d]
train_idx (np.ndarray) – Training indices
val_idx (np.ndarray) – Validation indices
test_idx (np.ndarray) – Test indices
labels (np.ndarray) – Node labels
seed (int) – Random seed
- Returns:
Classification metrics
- Return type:
dict
- evaluate_link_prediction(embeddings, test_edges, neg_test_edges)[source]#
Evaluate link prediction using dot product similarity.
- Parameters:
embeddings (np.ndarray) – Node embeddings [N, d]
test_edges (list) – Positive test edges
neg_test_edges (list) – Negative test edges
- Returns:
Link prediction metrics:
auc_roc,auc_pr,f1.- Return type:
dict
Notes
Ranking metrics are undefined unless both classes are present. When either
test_edgesorneg_test_edgesis empty the three metrics are returned asnan– not as 0.5 – because 0.5 is an achievable score and reporting it would make an undefined evaluation indistinguishable from a genuinely chance-level one, and would drag any average over methods toward chance. Aggregate these withnp.nanmean.- Raises:
ValueError – If both edge lists are empty, or if an edge references a node index outside
embeddings.
- evaluate_node_ranking(embeddings, seed_nodes, target_nodes, k_values=[10, 20, 50])[source]#
Evaluate node ranking task.
- Parameters:
embeddings (np.ndarray) – Node embeddings [N, d]
seed_nodes (list) – Seed node indices
target_nodes (list) – Target node indices
k_values (list) – K values for precision@k
- Returns:
Ranking metrics
- Return type:
dict
- run_node2vec_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for Node2Vec method.
- Return type:
Dict[str,float]
- run_netmf_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for NetMF method.
- Return type:
Dict[str,float]
- run_graphsage_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for GraphSAGE method.
- Return type:
Dict[str,float]
- run_appnp_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for APPNP method.
- Return type:
Dict[str,float]
- run_quvine_sgns(G, walk_type, config=None, seed=42)[source]#
Run QuVINE SGNS embedding with specified walk type.
- Parameters:
G (nx.Graph) – Input graph
walk_type (str) – Type of walk: ‘rwr’, ‘ctqw’, or ‘dtqw’
config (dict, optional) – Configuration parameters
seed (int) – Random seed
- Returns:
Node embeddings (n_nodes x embedding_dim)
- Return type:
np.ndarray
- run_quvine_rwr_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for QuVINE RWR (Random Walk with Restart + SGNS).
- Return type:
Dict[str,float]
- run_quvine_ctqw_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for QuVINE CTQW (Continuous-Time Quantum Walk + SGNS).
- Return type:
Dict[str,float]
- run_quvine_dtqw_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for QuVINE DTQW (Discrete-Time Quantum Walk + SGNS).
- Return type:
Dict[str,float]
- run_baseline_filter_heat_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for baseline heat kernel filter (no quantum calibration).
- Return type:
Dict[str,float]
- run_baseline_filter_poly_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for baseline polynomial filter (no quantum calibration).
- Return type:
Dict[str,float]
- generate_quantum_targets_from_walks(G, walk_type, config, seed, n_samples=10)[source]#
Generate quantum walk targets for filter calibration.
Samples subnetworks and computes quantum walk distributions. Returns targets with integer node IDs (not strings).
- Return type:
List[Dict]
- run_filter_rwr_heat_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for RWR + heat kernel filter.
- Return type:
Dict[str,float]
- run_filter_rwr_poly_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for RWR + polynomial filter.
- Return type:
Dict[str,float]
- run_filter_ctqw_heat_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for CTQW + heat kernel filter.
- Return type:
Dict[str,float]
- run_filter_ctqw_poly_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for CTQW + polynomial filter.
- Return type:
Dict[str,float]
- run_gat_adapter(G, split, task, method_name, config=None, seed=42)[source]#
Generic GAT adapter that handles all 12 GAT variants.
GAT variants differ only in their input features: - gat_baseline: raw structural features - gat_heat/poly: fixed filter parameters - gat_rwr/ctqw/dtqw: walk-based features - gat_*_heat/poly: quantum-calibrated filters
- Return type:
Dict[str,float]
- run_gat_baseline_adapter(G, split, task, config=None, seed=42)[source]#
GAT with raw structural features.
- run_gat_heat_adapter(G, split, task, config=None, seed=42)[source]#
GAT with fixed heat kernel features.
- run_gat_poly_adapter(G, split, task, config=None, seed=42)[source]#
GAT with fixed polynomial features.
- run_gat_rwr_heat_adapter(G, split, task, config=None, seed=42)[source]#
GAT with RWR-calibrated heat kernel features.
- run_gat_rwr_poly_adapter(G, split, task, config=None, seed=42)[source]#
GAT with RWR-calibrated polynomial features.
- run_gat_ctqw_heat_adapter(G, split, task, config=None, seed=42)[source]#
GAT with CTQW-calibrated heat kernel features.
- run_gat_ctqw_poly_adapter(G, split, task, config=None, seed=42)[source]#
GAT with CTQW-calibrated polynomial features.
- run_gat_dtqw_heat_adapter(G, split, task, config=None, seed=42)[source]#
GAT with DTQW-calibrated heat kernel features.
- run_gat_dtqw_poly_adapter(G, split, task, config=None, seed=42)[source]#
GAT with DTQW-calibrated polynomial features.
- run_graphgps_adapter(G, split, task, method_name, config=None, seed=42)[source]#
Generic GraphGPS adapter that handles all 12 GraphGPS variants.
GraphGPS variants differ only in their input features (same as GAT): - graphgps_baseline: raw structural features - graphgps_heat/poly: fixed filter parameters - graphgps_rwr/ctqw/dtqw: walk-based features - graphgps_*_heat/poly: quantum-calibrated filters
- Return type:
Dict[str,float]
- run_graphgps_baseline_adapter(G, split, task, config=None, seed=42)[source]#
GraphGPS with raw structural features.
- run_graphgps_heat_adapter(G, split, task, config=None, seed=42)[source]#
GraphGPS with fixed heat kernel features.
- run_graphgps_poly_adapter(G, split, task, config=None, seed=42)[source]#
GraphGPS with fixed polynomial features.
- run_graphgps_rwr_adapter(G, split, task, config=None, seed=42)[source]#
GraphGPS with RWR walk features.
- run_graphgps_ctqw_adapter(G, split, task, config=None, seed=42)[source]#
GraphGPS with direct CTQW features.
- run_graphgps_dtqw_adapter(G, split, task, config=None, seed=42)[source]#
GraphGPS with direct DTQW features.
- run_graphgps_rwr_heat_adapter(G, split, task, config=None, seed=42)[source]#
GraphGPS with RWR-calibrated heat kernel features.
- run_graphgps_rwr_poly_adapter(G, split, task, config=None, seed=42)[source]#
GraphGPS with RWR-calibrated polynomial features.
- run_graphgps_ctqw_heat_adapter(G, split, task, config=None, seed=42)[source]#
GraphGPS with CTQW-calibrated heat kernel features.
- run_graphgps_ctqw_poly_adapter(G, split, task, config=None, seed=42)[source]#
GraphGPS with CTQW-calibrated polynomial features.
- run_graphgps_dtqw_heat_adapter(G, split, task, config=None, seed=42)[source]#
GraphGPS with DTQW-calibrated heat kernel features.
- run_graphgps_dtqw_poly_adapter(G, split, task, config=None, seed=42)[source]#
GraphGPS with DTQW-calibrated polynomial features.
- run_baseline_gcnmf_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for baseline GCN-MF (no quantum calibration).
- Return type:
Dict[str,float]
- run_baseline_filter_adapter(G, split, task, config=None, seed=42)[source]#
Adapter for generic baseline filter (defaults to heat kernel).
This is the generic ‘baseline_filter’ method that can be configured to use either heat or polynomial filters via config[‘filter_type’]. Defaults to heat kernel for backward compatibility.
- Return type:
Dict[str,float]
- run_rwr_fusion_adapter(G, split, task, config=None, seed=42)[source]#
Fusion method combining RWR-based embeddings.
Combines: - quvine_rwr (SGNS with RWR) - filter_rwr_heat (RWR-calibrated heat kernel) - filter_rwr_poly (RWR-calibrated polynomial)
Uses SVD-based fusion to combine the three views.
- Return type:
Dict[str,float]
- run_ctqw_fusion_adapter(G, split, task, config=None, seed=42)[source]#
Fusion method combining CTQW-based embeddings.
Combines: - quvine_ctqw (SGNS with CTQW) - filter_ctqw_heat (CTQW-calibrated heat kernel) - filter_ctqw_poly (CTQW-calibrated polynomial)
Uses SVD-based fusion to combine the three views.
- Return type:
Dict[str,float]
- run_dtqw_fusion_adapter(G, split, task, config=None, seed=42)[source]#
Fusion method combining DTQW-based embeddings.
Combines: - quvine_dtqw (SGNS with DTQW) - Baseline heat kernel (as DTQW doesn’t have filter variants) - Baseline polynomial (as DTQW doesn’t have filter variants)
Uses SVD-based fusion to combine the three views. Note: DTQW doesn’t have dedicated filter variants, so we use baseline filters.
- Return type:
Dict[str,float]