saealib.SklearnRFRSurrogate#

class saealib.SklearnRFRSurrogate(**kwargs)[source]#

Bases: SklearnSurrogate

Random Forest Regressor surrogate.

Convenience wrapper around SklearnSurrogate using sklearn.ensemble.RandomForestRegressor.

Parameters:

**kwargs (object) – Keyword arguments forwarded to sklearn.ensemble.RandomForestRegressor.

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

SklearnRFRSurrogate.__init__(**kwargs)[source]#
Parameters:

kwargs (object)

Return type:

None

SklearnRFRSurrogate.contract()#

Return the surrogate model contract.

Return type:

ComponentContract

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

Return type:

None

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

SklearnRFRSurrogate.predict(test_x)#

Predict using the surrogate model.

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 is None

Return type:

SurrogatePrediction

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