saealib.ComparisonSurrogate#

class saealib.ComparisonSurrogate[source]#

Bases: Surrogate

Base class for relative-fitness (comparison) surrogates.

Subclass this when train_y holds binary comparison labels {0, 1} and predictions are win-probability estimates in [0, 1].

predict_proba is the primary interface; predict delegates to it by default so that managers designed for Surrogate still work.

Methods

__init__

contract

Return the surrogate model contract.

fit

Fit the surrogate model.

post_fit

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

predict

Delegate to predict_proba.

predict_proba

Return win-probability estimates.

with_post_fit

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

Method Details

ComparisonSurrogate.__init__()#
ComparisonSurrogate.contract()#

Return the surrogate model contract.

Return type:

ComponentContract

abstractmethod ComparisonSurrogate.fit(train_x, train_y)#

Fit the surrogate model.

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) For n_obj == 1, shape (n_samples,) is also accepted.

Return type:

None

ComparisonSurrogate.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

ComparisonSurrogate.predict(test_x)[source]#

Delegate to predict_proba.

Parameters:

test_x (ndarray)

Return type:

SurrogatePrediction

abstractmethod ComparisonSurrogate.predict_proba(test_x)[source]#

Return win-probability estimates.

Parameters:

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

Returns:

value shape: (n_samples, 1), values in [0, 1]. std is None unless the model supports uncertainty.

Return type:

SurrogatePrediction

ComparisonSurrogate.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