qbiocode.apps.quvine.reproducibility.split_generator module#
Task Split Generator for QuVINE
Generates and saves task-specific data splits to ensure all methods use identical splits.
Summary#
Classes:
Generates and saves task-specific splits for reproducible benchmarking. |
Reference#
- class SplitGenerator(output_dir, seed_manager, registry)[source]#
Bases:
objectGenerates and saves task-specific splits for reproducible benchmarking.
All splits are pre-generated once and saved to disk. Methods then load these pre-generated splits instead of creating their own.
Supports three tasks: 1. Node Classification: train/val/test node indices + labels 2. Link Prediction: train/val/test edge splits + negative samples 3. Node Ranking: target nodes for ranking evaluation
- __init__(output_dir, seed_manager, registry)[source]#
Initialize split generator.
- Parameters:
output_dir (Path) – Root directory for saving splits
seed_manager (SeedManager) – Seed manager for reproducible split generation
registry (DatasetRegistry) – Dataset registry to update with split paths
- generate_all_splits(dataset_name, repetition_id, G, tasks=['node_classification', 'link_prediction', 'node_ranking'], disease_nodes=None, task_config=None, split_base_dir=None)[source]#
Generate all task splits for a dataset.
- Parameters:
dataset_name (str) – Dataset name
repetition_id (int) – Repetition ID
G (nx.Graph) – Graph to generate splits for
tasks (List[str]) – Tasks to generate splits for
- Returns:
Mapping from task name to split file path
- Return type:
Dict[str, Path]
- generate_node_classification_split(dataset_name, repetition_id, G, train_ratio=0.6, val_ratio=0.2, test_ratio=0.2, min_class_size=5, disease_nodes=None, positive_class_definition='disease_seed_or_target', negative_class_definition='non_disease_nodes', split_strategy='stratified', split_base_dir=None)[source]#
Generate node classification split with synthetic labels.
Labels are generated using community detection (Louvain).
- Parameters:
dataset_name (str) – Dataset name
repetition_id (int) – Repetition ID
G (nx.Graph) – Graph
train_ratio (float) – Training set ratio
val_ratio (float) – Validation set ratio
test_ratio (float) – Test set ratio
min_class_size (int) – Minimum nodes per class
- Returns:
Path to saved split file
- Return type:
Path
- generate_link_prediction_split(dataset_name, repetition_id, G, train_ratio=0.85, val_ratio=0.05, test_ratio=0.1, negative_sampling_ratio=1.0, disease_nodes=None, protect_disease_edges=True, split_strategy='random_edge_split', negative_sampling_strategy='random', split_base_dir=None)[source]#
Generate link prediction split with held-out edges and negative samples.
- Parameters:
dataset_name (str) – Dataset name
repetition_id (int) – Repetition ID
G (nx.Graph) – Graph
train_ratio (float) – Training edges ratio
val_ratio (float) – Validation edges ratio
test_ratio (float) – Test edges ratio
negative_sampling_ratio (float) – Ratio of negative to positive samples
- Returns:
Path to saved split file
- Return type:
Path
- generate_node_ranking_split(dataset_name, repetition_id, G, n_targets=None, target_selection='high_degree', n_seeds=None, seed_selection='random', disease_nodes=None, excluded_nodes=None, selection_rule=None, split_base_dir=None)[source]#
Generate node ranking split with seed and target nodes.
For PPI networks, this should use disease-specific seeds/targets. For synthetic networks, generates synthetic seeds/targets.
- Parameters:
dataset_name (str) – Dataset name
repetition_id (int) – Repetition ID
G (nx.Graph) – Graph
n_targets (int, optional) – Number of target nodes (default: 10% of nodes)
target_selection (str) – Target selection strategy (‘high_degree’, ‘random’, ‘central’)
n_seeds (int, optional) – Number of seed nodes (default: 5% of nodes)
seed_selection (str) – Seed selection strategy (‘random’, ‘high_degree’)
- Returns:
Path to saved split file
- Return type:
Path