AutoMAX
- class AutoMAX(trainer, config, target)
Automated AUC optimisation using SMAC3.
Wraps a LibAUC
Trainerwith a SMAC3HyperparameterOptimizationFacadeto perform Bayesian hyperparameter search over the configuration space exposed by trainer.- Parameters:
trainer (callable) – A callable (typically an
autopartialinstance) that accepts aspaceargument and returns aTrainer. The.csattribute of the trainer is used as the SMAC3 configuration space.config (
AutoMAXConfigration) – Run-level settings (number of trials, output directory, seed …).target (str) – Name of the metric to maximise (e.g.
"AUROC").
Example
from src.core import AutoMAX, AutoMAXConfigration config = AutoMAXConfigration( name="my_search", n_trials=10, n_configs=1, SEED=42, output_directory="./automax_output", overwrite=True, deterministic=True, ) tuner = AutoMAX(trainer=my_autopartial_trainer, config=config, target="AUROC") tuner.optimize()
Constructor details
- __init__(trainer, config, target)
Initialises the SMAC3 scenario and
HyperparameterOptimizationFacade. If config.overwrite isFalseand a previous run exists, the trial log is restored fromstate.pkl.
Methods
- train(space, seed=0) float
Train one model with the hyperparameter configuration space.
Called automatically by SMAC3 during optimisation; you rarely need to call this directly.
- Parameters:
space – A SMAC3 / ConfigSpace
Configurationobject.seed (int) – Random seed for this trial (passed in by SMAC3).
- Returns:
Negative validation score (SMAC3 minimises cost).
- Return type:
float
After training the method:
Appends the trial summary to
self.log.Persists
self.logto<output_directory>/<name>/state.pkl.Copies the model checkpoint directory to
<experiment_name>_bestwhenever a new best score is found.
- optimize() Configuration
Run the full SMAC3 optimisation loop and print a trial-history table.
Resumes any interrupted trials before calling
optimize().- Returns:
The incumbent (best) configuration found.
- Return type:
Configuration
Trial history table — printed to stdout after optimisation:
---------------------------------------- Trial Val AUROC ---------------------------------------- 1 0.823456 2 0.851234 … ----------------------------------------
Attributes
Attribute
Description
configspaceThe
ConfigurationSpacetaken from trainer.trainerThe wrapped trainer callable.
targetMetric name string (e.g.
"AUROC").configThe
AutoMAXConfigrationinstance.smacThe underlying
HyperparameterOptimizationFacadeinstance.logList of per-trial summary dicts (
val,test,space, …).finishedNumber of completed trials at initialisation time.
best_scoreRunning best validation score (
float('-inf')at start).