pyGPGO.surrogates.RandomForest module

class pyGPGO.surrogates.RandomForest.ExtraForest(**params)[source]

Bases: object

Wrapper around sklearn’s ExtraTreesRegressor implementation for pyGPGO. Random Forests can also be used for surrogate models in Bayesian Optimization. An estimate of ‘posterior’ variance can be obtained by using the impurity criterion value in each subtree.

Parameters:params (tuple, optional) – Any parameters to pass to RandomForestRegressor. Defaults to sklearn’s.
__init__(**params)[source]

Wrapper around sklearn’s ExtraTreesRegressor implementation for pyGPGO. Random Forests can also be used for surrogate models in Bayesian Optimization. An estimate of ‘posterior’ variance can be obtained by using the impurity criterion value in each subtree.

Parameters:params (tuple, optional) – Any parameters to pass to RandomForestRegressor. Defaults to sklearn’s.
fit(X, y)[source]

Fit a Random Forest model to data X and targets y.

Parameters:
  • X (array-like) – Input values.
  • y (array-like) – Target values.
predict(Xstar, return_std=True, eps=1e-06)[source]

Predicts ‘posterior’ mean and variance for the RF model.

Parameters:
  • Xstar (array-like) – Input values.
  • return_std (bool, optional) – Whether to return posterior variance estimates. Default is True.
  • eps (float, optional) – Floating precision value for negative variance estimates. Default is 1e-6
Returns:

  • array-like – Posterior predicted mean.
  • array-like – Posterior predicted std

update(xnew, ynew)[source]

Updates the internal RF model with observations xnew and targets ynew.

Parameters:
  • xnew (array-like) – New observations.
  • ynew (array-like) – New targets.
class pyGPGO.surrogates.RandomForest.RandomForest(**params)[source]

Bases: object

Wrapper around sklearn’s Random Forest implementation for pyGPGO. Random Forests can also be used for surrogate models in Bayesian Optimization. An estimate of ‘posterior’ variance can be obtained by using the impurity criterion value in each subtree.

Parameters:params (tuple, optional) – Any parameters to pass to RandomForestRegressor. Defaults to sklearn’s.
__init__(**params)[source]

Wrapper around sklearn’s Random Forest implementation for pyGPGO. Random Forests can also be used for surrogate models in Bayesian Optimization. An estimate of ‘posterior’ variance can be obtained by using the impurity criterion value in each subtree.

Parameters:params (tuple, optional) – Any parameters to pass to RandomForestRegressor. Defaults to sklearn’s.
fit(X, y)[source]

Fit a Random Forest model to data X and targets y.

Parameters:
  • X (array-like) – Input values.
  • y (array-like) – Target values.
predict(Xstar, return_std=True, eps=1e-06)[source]

Predicts ‘posterior’ mean and variance for the RF model.

Parameters:
  • Xstar (array-like) – Input values.
  • return_std (bool, optional) – Whether to return posterior variance estimates. Default is True.
  • eps (float, optional) – Floating precision value for negative variance estimates. Default is 1e-6
Returns:

  • array-like – Posterior predicted mean.
  • array-like – Posterior predicted std

update(xnew, ynew)[source]

Updates the internal RF model with observations xnew and targets ynew.

Parameters:
  • xnew (array-like) – New observations.
  • ynew (array-like) – New targets.