| active_learning {gptools2} | R Documentation |
Active learning with surrogate function
active_learning(
X,
f,
surrogate = gp_surrogate$new,
max_iter,
tol,
persistence = 1,
consecutive = -1,
parallel = FALSE,
mc.cores = 1,
restart,
options = list(),
callback,
...
)
X |
A list of evaluation points. |
f |
A function; the objective function. |
surrogate |
A function; the surrogate class of object. |
max_iter |
A positive integer; the maximum iterations. |
tol |
A numeric vector of length two; the mean-squared-error and out-of-sample-predictive variance tolerance for convergence. |
persistence |
A positive integer; the number of times the tolerance should be reached before convergence. Use -1 to disable this option. |
consecutive |
A positive integer; the number of consecutive times the tolerance should be reached before convergence. Use -1 to disable this option. |
parallel |
TRUE or FALSE; whether to use parallel computing. |
mc.cores |
A positive integer; the number of cores to use for parallel computing. Only works when 'parallel = TRUE'. |
restart |
The fitted model from previous run. |
options |
Optional argument to pass to |
callback |
Optional function to be called after each iteration of update; this lets users examine the fitting process. |
... |
Optional arguments to pass to the surrogate function. |
A model object returned by the surrogate function.
## Not run:
library(gptools2)
s <- seq(-5, 5, length.out = 3)
X <- as.matrix(expand.grid(s, s))
f <- function(x) sin(x[1]) + x[2]
model <- active_learning(
X, f, sigma = 1e-3,
max_iter = 100, tol = c(0.1, 0.01)
)
# In-sample fit
pred_y <- predict_gp(model$model, X)
y <- map_row(X, f)
compare(y, pred_y$mean)
# Out-of-sample performance
new_X <- as.matrix(expand.grid(runif(10, -4, 4), runif(10, -4, 4)))
new_y <- map_row(new_X, f)
new_pred_y <- predict_gp(model$model, new_X)
compare(new_y, new_pred_y$mean)
## End(Not run)