dgp {dgpsi} | R Documentation |
This function builds and trains a DGP emulator.
dgp(
X,
Y,
struc = NULL,
depth = 2,
name = "sexp",
lengthscale = 1,
share = TRUE,
nugget_est = FALSE,
nugget = 1e-06,
connect = TRUE,
likelihood = NULL,
training = TRUE,
verb = TRUE,
check_rep = TRUE,
rff = FALSE,
M = NULL,
N = 500,
ess_burn = 10,
burnin = NULL,
B = 50,
internal_input_idx = NULL,
linked_idx = NULL
)
X |
a matrix where each row is an input training data point and each column is an input dimension. |
Y |
a matrix containing observed training output data. The matrix has its rows being output data points and columns being
output dimensions. When |
struc |
a list that specifies a user-defined DGP structure. It should contain L (the number of DGP layers) sub-lists,
each of which represents a layer and contains a number of GP nodes (defined by |
depth |
number of layers (including the likelihood layer) for a DGP structure. |
name |
kernel function to be used. Either |
lengthscale |
initial lengthscales for GP nodes in the DGP emulator. It can be a single numeric value or a vector:
Defaults to a numeric value of |
share |
a bool indicating if all input dimensions of a GP node share a common lengthscale. Defaults to |
nugget_est |
a bool or a bool vector that indicates if the nuggets of GP nodes (if any) in the final layer are to be estimated. If a single bool is
provided, it will be applied to all GP nodes (if any) in the final layer. If a bool vector (which must have a length of
Defaults to |
nugget |
the initial nugget value(s) of GP nodes (if any) in the final layer. If it is a single numeric value, it will be applied to all GP nodes (if any)
in the final layer. If it is a vector (which must have a length of |
connect |
a bool indicating whether to implement global input connection to the DGP structure. Defaults to |
likelihood |
the likelihood type of a DGP emulator:
When |
training |
a bool indicating if the initialized DGP emulator will be trained.
When set to |
verb |
a bool indicating if the trace information on DGP emulator construction and training will be printed during the function execution.
Defaults to |
check_rep |
a bool indicating whether to check the repetitions in the dataset, i.e., if one input
position has multiple outputs. Defaults to |
rff |
a bool indicating whether to use random Fourier features to approximate the correlation matrices in training. Turning on this option could help accelerate
the training when the training data is relatively large but may reduce the quality of the resulting emulator. Defaults to |
M |
the number of features to be used by random Fourier approximation. It is only used
when |
N |
number of iterations for the training. Defaults to |
ess_burn |
number of burnin steps for the ESS-within-Gibbs
at each I-step of the training. Defaults to |
burnin |
the number of training iterations to be discarded for
point estimates of model parameters. Must be smaller than the training iterations |
B |
the number of imputations to produce the later predictions. Increase the value to account for
more imputation uncertainties. Decrease the value for lower imputation uncertainties but faster predictions.
Defaults to |
internal_input_idx |
column indices of |
linked_idx |
either a vector or a list of vectors:
Set |
See further examples and tutorials at https://mingdeyu.github.io/dgpsi-R/ and learn how to customize a DGP structure.
An S3 class named dgp
that contains three slots:
constructor_obj
: a 'python' object that stores the information of the constructed DGP emulator.
container_obj
: a 'python' object that stores the information for the linked emulation.
emulator_obj
: a 'python' object that stores the information for the predictions from the DGP emulator.
The returned dgp
object can be used by
predict()
for DGP predictions.
continue()
for additional DGP training iterations.
validate()
for LOO and OOS validations.
plot()
for validation plots.
lgp()
for linked (D)GP emulator constructions.
Any R vector detected in X
and Y
will be treated as a column vector and automatically converted into a single-column
R matrix.
## Not run:
# load the package and the Python env
library(dgpsi)
init_py()
# construct a step function
f <- function(x) {
if (x < 0.5) return(-1)
if (x >= 0.5) return(1)
}
# generate training data
X <- seq(0, 1, length = 10)
Y <- sapply(X, f)
# training a 3-layered DGP emulator
m <- dgp(X, Y, depth = 3)
# continue for further training iterations
m <- continue(m)
# summarizing
summary(m)
# trace plot
trace_plot(m)
# LOO cross validation
m <- validate(m)
plot(m)
# prediction
test_x <- seq(0, 1, length = 200)
m <- predict(m, x = test_x)
# OOS validation
validate_x <- sample(test_x, 10)
validate_y <- sapply(validate_x, f)
plot(m, validate_x, validate_y)
# write and read the constructed emulator
write(m, 'step_dgp')
m <- read('step_dgp')
## End(Not run)