saealib.PerObjectiveSurrogate#

class saealib.PerObjectiveSurrogate(surrogates)[source]#

Bases: RegressionSurrogate

Assigns a different surrogate model to each objective function.

Each surrogate in surrogates is fitted on the corresponding column of train_y. Predictions are concatenated along the objective axis.

If every surrogate has provides_uncertainty = True, the returned SurrogatePrediction.std is populated by stacking each surrogate’s std output; otherwise std is None.

Parameters:

surrogates (list[Surrogate]) – One surrogate per objective. Must be non-empty.

Raises:

ValueError – If surrogates is empty, or if the number of objectives in train_y does not match len(surrogates) at fit time.

Methods

__init__

contract

Return the surrogate model contract.

fit

Fit each surrogate on its corresponding objective column.

post_fit

Post-fit lifecycle hook; override to inject custom processing.

predict

Predict by combining each surrogate's output.

with_post_fit

Return a copy of this surrogate with fn appended to the post-fit hook.

Method Details

PerObjectiveSurrogate.__init__(surrogates)[source]#
Parameters:

surrogates (list[Surrogate])

Return type:

None

PerObjectiveSurrogate.contract()#

Return the surrogate model contract.

Return type:

ComponentContract

PerObjectiveSurrogate.fit(train_x, train_y)[source]#

Fit each surrogate on its corresponding objective column.

Parameters:
  • train_x (np.ndarray) – Training input data. shape: (n_samples, n_features)

  • train_y (np.ndarray) – Training output data. shape: (n_samples, n_obj) or (n_samples,).

Return type:

None

PerObjectiveSurrogate.post_fit(train_x, train_y, ctx=None)#

Post-fit lifecycle hook; override to inject custom processing.

Parameters:
  • train_x (np.ndarray) – Training input data used for this fit. shape: (n_samples, n_features)

  • train_y (np.ndarray) – Training output data used for this fit. shape: (n_samples, n_obj)

  • ctx (OptimizationState or None, optional) – Current optimization context.

Return type:

None

PerObjectiveSurrogate.predict(test_x)[source]#

Predict by combining each surrogate’s output.

Parameters:

test_x (np.ndarray) – Input data. shape: (n_samples, n_features) or (n_features,)

Returns:

prediction.value shape: (n_samples, n_obj) prediction.std shape: (n_samples, n_obj) if all surrogates provide uncertainty, otherwise None. prediction.x holds the (n_samples, n_features) query points passed to this call, set directly from test_x regardless of whether the wrapped surrogates populate their own x (needed by acquisition functions such as CORSDistance).

Return type:

SurrogatePrediction

PerObjectiveSurrogate.with_post_fit(fn)#

Return a copy of this surrogate with fn appended to the post-fit hook.

Parameters:

fn (callable) – fn(train_x, train_y, ctx) -> None

Returns:

Shallow copy with the hook registered.

Return type:

Surrogate