scxpand.hyperopt.hyperopt_optimizer#
Hyperparameter optimization using Optuna with robust trial management.
Classes
|
Robust hyperparameter optimizer using Optuna with enhanced trial management. |
- class scxpand.hyperopt.hyperopt_optimizer.HyperparameterOptimizer(model_type, data_path, study_name=None, storage_path='results/optuna_studies', score_metric='harmonic_avg/AUROC', seed_base=42, num_workers=0, config_path=None, resume=True, fail_fast=False, **param_overrides)#
Robust hyperparameter optimizer using Optuna with enhanced trial management.
Features: - Automatic cleanup of incomplete trials - Proper exception handling and categorization - Resume capability with duplicate prevention - Comprehensive logging and monitoring
- __init__(model_type, data_path, study_name=None, storage_path='results/optuna_studies', score_metric='harmonic_avg/AUROC', seed_base=42, num_workers=0, config_path=None, resume=True, fail_fast=False, **param_overrides)#
Initialize the hyperparameter optimizer.
- Parameters:
model_type (
ModelType|str) – Type of model to optimize (MLP, SVM, etc.).study_name (
str|None(default:None)) – Name for the Optuna study (auto-generated if None).storage_path (
str|Path(default:'results/optuna_studies')) – Directory to store study results.score_metric (
str(default:'harmonic_avg/AUROC')) – Metric to optimize (e.g., “harmonic_avg/AUROC”).seed_base (
int(default:42)) – Base seed for reproducibility.num_workers (
int(default:0)) – Number of parallel workers (0 for single-threaded).config_path (
str|None(default:None)) – Path to configuration file for parameter overrides.resume (
bool(default:True)) – Whether to resume existing study (False = start fresh).fail_fast (
bool(default:False)) – Whether to fail immediately on any exception (for testing).**param_overrides – Additional parameter overrides.
- create_study()#
Create or load an Optuna study based on the resume setting.
- Return type:
- Returns:
The Optuna study object.
- Raises:
ValueError – If study exists but resume=False.
- objective(trial)#
Objective function for Optuna trials.
- print_results(study=None)#
Print optimization results.