qbiocode.apps.quvine.baselines.hyperparameter_loader module#
Hyperparameter Loader for Tuned Methods
This module loads pre-tuned hyperparameters from JSON files and overrides config defaults. Each dataset has its own tuning file with task-specific parameters (node_classification, link_prediction, node_ranking).
Summary#
Classes:
Loads and manages tuned hyperparameters from JSON files. |
Functions:
Get the global hyperparameter loader. |
|
Convenience function to override config with tuned hyperparameters. |
|
Set the global hyperparameter loader. |
Reference#
- class HyperparameterLoader(tuning_dir=None, dataset_name=None)[source]#
Bases:
objectLoads and manages tuned hyperparameters from JSON files.
Example JSON structure:
{ "node2vec": { "node2vec": { "node_classification": {"best_params": {...}, "best_score": 0.5}, "link_prediction": {"best_params": {...}, "best_score": 0.9}, "node_ranking": {"best_params": {...}, "best_score": 0.4} } }, ... }
- __init__(tuning_dir=None, dataset_name=None)[source]#
Initialize hyperparameter loader.
- Parameters:
tuning_dir (
Optional[str]) – Directory containing tuning JSON filesdataset_name (
Optional[str]) – Name of the dataset (e.g., ‘scale_free’, ‘BioPlex3_autism’)
- load_hyperparameters()[source]#
Load hyperparameters from JSON file.
Tries multiple filename patterns: 1. {dataset_name}_tuning_by_task.json (new format) 2. {dataset_name}_aggregated.json (legacy format)
- Return type:
bool- Returns:
True if loaded successfully, False otherwise
- get_method_params(method_name, task='node_classification')[source]#
Get tuned parameters for a method and task.
- Parameters:
method_name (
str) – Name of the method (e.g., ‘node2vec’, ‘gat_ctqw_heat’)task (
str) – Task type (‘node_classification’, ‘link_prediction’, ‘node_ranking’)
- Return type:
Optional[Dict[str,Any]]- Returns:
Dictionary of best parameters, or None if not found
- override_config(config, method_name, task='node_classification')[source]#
Override config object with tuned hyperparameters.
- Parameters:
config – Config dataclass object
method_name (
str) – Name of the methodtask (
str) – Task type
- Returns:
Updated config object (new instance via dataclass replace)
- override_nested_config(config, method_name, task='node_classification')[source]#
Override nested config objects (for GAT/GraphGPS with model and train configs).
- Parameters:
config – Config dataclass with nested model and train configs
method_name (
str) – Name of the methodtask (
str) – Task type
- Returns:
Updated config object
- get_global_loader()[source]#
Get the global hyperparameter loader.
- Return type:
Optional[HyperparameterLoader]