saealib.ComparisonSurrogate#

class saealib.ComparisonSurrogate[ソース]#

ベースクラス: 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.

戻り値の型:

ComponentContract

abstractmethod ComparisonSurrogate.fit(train_x, train_y)#

Fit the surrogate model.

パラメータ:
  • 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.

戻り値の型:

None

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

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

パラメータ:
  • 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.

戻り値の型:

None

ComparisonSurrogate.predict(test_x)[ソース]#

Delegate to predict_proba.

パラメータ:

test_x (ndarray)

戻り値の型:

SurrogatePrediction

abstractmethod ComparisonSurrogate.predict_proba(test_x)[ソース]#

Return win-probability estimates.

パラメータ:

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

戻り値:

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

戻り値の型:

SurrogatePrediction

ComparisonSurrogate.with_post_fit(fn)#

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

パラメータ:

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

戻り値:

Shallow copy with the hook registered.

戻り値の型:

Surrogate