saealib.SklearnSurrogate#

class saealib.SklearnSurrogate(estimator)[ソース]#

ベースクラス: RegressionSurrogate

Surrogate adapter for scikit-learn compatible estimators.

Wraps any estimator that implements fit(X, y) and predict(X). Multi-objective problems are handled by fitting one cloned estimator per objective, following the same pattern as RBFSurrogate.

パラメータ:

estimator (sklearn estimator) -- A scikit-learn compatible regressor instance (e.g. SVR()). The estimator is cloned once per objective on the first fit call.

例外:

ImportError -- If scikit-learn is not installed.

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

Predict using the surrogate model.

with_post_fit

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

Method Details

SklearnSurrogate.__init__(estimator)[ソース]#
パラメータ:

estimator (object)

戻り値の型:

None

SklearnSurrogate.contract()#

Return the surrogate model contract.

戻り値の型:

ComponentContract

SklearnSurrogate.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) or (n_samples,).

戻り値の型:

None

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

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

Predict using the surrogate model.

パラメータ:

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

戻り値:

prediction.value shape: (n_samples, n_obj) prediction.std is None

戻り値の型:

SurrogatePrediction

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