AutoMAX

class AutoMAX(trainer, config, target)

Automated AUC optimisation using SMAC3.

Wraps a LibAUC Trainer with a SMAC3 HyperparameterOptimizationFacade to perform Bayesian hyperparameter search over the configuration space exposed by trainer.

Parameters:
  • trainer (callable) – A callable (typically an autopartial instance) that accepts a space argument and returns a Trainer. The .cs attribute 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 is False and a previous run exists, the trial log is restored from state.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 Configuration object.

  • 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.log to <output_directory>/<name>/state.pkl.

  • Copies the model checkpoint directory to <experiment_name>_best whenever 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

configspace

The ConfigurationSpace taken from trainer.

trainer

The wrapped trainer callable.

target

Metric name string (e.g. "AUROC").

config

The AutoMAXConfigration instance.

smac

The underlying HyperparameterOptimizationFacade instance.

log

List of per-trial summary dicts (val, test, space, …).

finished

Number of completed trials at initialisation time.

best_score

Running best validation score (float('-inf') at start).