ALC | R Documentation |
Acts on a gp
, dgp2
, or dgp3
object.
Current version requires squared exponential covariance
(cov = "exp2"
). Calculates ALC over the input locations
x_new
using specified reference grid. If no reference grid is
specified, x_new
is used as the reference. Optionally utilizes
SNOW parallelization. User should
select the point with the highest ALC to add to the design.
ALC(object, x_new, ref, cores) ## S3 method for class 'gp' ALC(object, x_new = NULL, ref = NULL, cores = 1) ## S3 method for class 'dgp2' ALC(object, x_new = NULL, ref = NULL, cores = 1) ## S3 method for class 'dgp3' ALC(object, x_new = NULL, ref = NULL, cores = 1)
object |
object of class |
x_new |
matrix of possible input locations, if object has been run
through |
ref |
optional reference grid for ALC approximation, if |
cores |
number of cores to utilize in parallel, by default no parallelization is used |
Not yet implemented for Vecchia-approximated fits.
All iterations in the object are used in the calculation, so samples
should be burned-in. Thinning the samples using trim
will
speed up computation. This function may be used in two ways:
Option 1: called on an object with only MCMC iterations, in
which case x_new
must be specified
Option 2: called on an object that has been predicted over, in
which case the x_new
from predict
is used
In Option 2, it is recommended to set store_latent = TRUE
for
dgp2
and dgp3
objects so
latent mappings do not have to be re-calculated. Through predict
,
the user may specify a mean mapping (mean_map = TRUE
) or a full
sample from the MVN distribution over w_new
(mean_map = FALSE
). When the object has not yet been predicted
over (Option 1), the mean mapping is used.
SNOW parallelization reduces computation time but requires more memory storage. C code derived from the "laGP" package (Robert B Gramacy and Furong Sun).
list with elements:
value
: vector of ALC values, indices correspond to x_new
time
: computation time in seconds
Sauer, A, RB Gramacy, and D Higdon. 2020. "Active Learning for Deep Gaussian
Process Surrogates." Technometrics, to appear; arXiv:2012.08015.
Seo, S, M Wallat, T Graepel, and K Obermayer. 2000. Gaussian Process Regression:
Active Data Selection and Test Point Rejection. In Mustererkennung 2000,
2734. New York, NY: SpringerVerlag.
Gramacy, RB and F Sun. (2016). laGP: Large-Scale Spatial Modeling via Local
Approximate Gaussian Processes in R. Journal of Statistical Software
72 (1), 1-46. doi:10.18637/jss.v072.i01
# -------------------------------------------------------- # Example 1: toy step function, runs in less than 5 seconds # -------------------------------------------------------- f <- function(x) { if (x <= 0.4) return(-1) if (x >= 0.6) return(1) if (x > 0.4 & x < 0.6) return(10*(x-0.5)) } x <- seq(0.05, 0.95, length = 7) y <- sapply(x, f) x_new <- seq(0, 1, length = 100) # Fit model and calculate ALC fit <- fit_two_layer(x, y, nmcmc = 100, cov = "exp2") fit <- trim(fit, 50) fit <- predict(fit, x_new, cores = 1, store_latent = TRUE) alc <- ALC(fit) # -------------------------------------------------------- # Example 2: damped sine wave # -------------------------------------------------------- f <- function(x) { exp(-10*x) * (cos(10*pi*x - 1) + sin(10*pi*x - 1)) * 5 - 0.2 } # Training data x <- seq(0, 1, length = 30) y <- f(x) + rnorm(30, 0, 0.05) # Testing data xx <- seq(0, 1, length = 100) yy <- f(xx) plot(xx, yy, type = "l") points(x, y, col = 2) # Conduct MCMC (can replace fit_two_layer with fit_one_layer/fit_three_layer) fit <- fit_two_layer(x, y, D = 1, nmcmc = 2000, cov = "exp2") plot(fit) fit <- trim(fit, 1000, 2) # Option 1 - calculate ALC from MCMC iterations alc <- ALC(fit, xx) # Option 2 - calculate ALC after predictions fit <- predict(fit, xx, cores = 1, store_latent = TRUE) alc <- ALC(fit) # Visualize fit plot(fit) par(new = TRUE) # overlay ALC plot(xx, alc$value, type = 'l', lty = 2, axes = FALSE, xlab = '', ylab = '') # Select next design point x_new <- xx[which.max(alc$value)]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.