pdmlabs.optimization.base#
Abstract base class for all PdMLabs optimizer adapters.
Classes
Abstract base for optimizer adapters. |
- class pdmlabs.optimization.base.BaseOptimizerAdapter#
Bases:
ABCAbstract base for optimizer adapters.
Subclasses translate the PdMLabs native param space (dict of str -> list | rv_frozen) into their backendβs representation and expose a unified maximize / minimize API.
The raw objective function passed to adapters has the signature:
def optimization_objective(**params) -> float
Each adapter is responsible for wrapping it into whatever calling convention its backend requires (batch list, single config, etc.).
A single float is the whole contract: anything else a trial produces (its threshold, its fitted pipeline) travels back to the main process through
pdmlabs.optimization.trial_sink.TrialSink, which the objective closure carries into the workers. Adapters neither see nor forward it, so they need no changes to support it.- abstract maximize(param_space: dict, objective_fn, n_iterations: int, n_jobs: int, initial_random: int, constraint_fn=None) dict#
Run optimization maximizing objective_fn over param_space.
- Parameters:
param_space β PdMLabs native space β
str->listorrv_frozen.objective_fn β Raw callable
(**params) -> float(single config, single score). Adapters wrap this into whatever their backend expects.n_iterations β Number of optimizer iterations / trials.
n_jobs β Degree of parallelism (adapter-specific meaning).
initial_random β Number of random warm-up evaluations (Mango only; ignored by SMAC).
constraint_fn β Optional constraint predicate on parameter dicts (Mango only).
- Returns:
Keys:
best_params(dict),best_objective(float),params_tried(list[dict]),objective_values(list[float]).- Return type:
dict
- minimize(param_space: dict, objective_fn, n_iterations: int, n_jobs: int, initial_random: int, constraint_fn=None) dict#
Minimize by negating objective_fn and delegating to maximize.
- supports_categorical: bool = True#