R interface to Python's GPopt.GenericSurrogate. Turns an arbitrary scikit-learn-compatible regressor (obtained e.g. with [get_sklearn()]) into a conformalized and/or Bayesian surrogate model, usable as the `surrogate_obj` argument of [GPOpt()] instead of the default Gaussian Process Regression surrogate.

GenericSurrogate(
  base_model,
  conformal = TRUE,
  bayesian = FALSE,
  venv_path = "./venv"
)

Arguments

base_model

a Python scikit-learn-compatible regressor *instance* (not a class), e.g. `get_sklearn(venv_path)$ensemble$ExtraTreesRegressor()`

conformal

logical, whether to conformalize the surrogate's predictions (for calibrated uncertainty quantification)

bayesian

logical, whether to use a Bayesian variant of the surrogate

venv_path

path to the Python virtual environment created with `uv` (see the package README for setup instructions)

Value

A Python `GPopt.GenericSurrogate` object, with scikit-learn-style members accessible with `$`: `$fit(X, y)`, `$predict(X)`, `$score(X, y)`, `$get_params()`, `$set_params(...)`.

Examples

if (FALSE) { # \dontrun{
sklearn <- get_sklearn(venv_path = "./venv")
base_model <- sklearn$ensemble$ExtraTreesRegressor()
surrogate <- GenericSurrogate(base_model, conformal = TRUE, venv_path = "./venv")

opt <- GPOpt(
  lower_bound = c(-5, 0),
  upper_bound = c(10, 15),
  objective_func = function(x) sum(x^2),
  surrogate_obj = surrogate,
  venv_path = "./venv"
)
} # }