WrappedGP {GPTreeO} | R Documentation |
R6 class WrappedGP
Description
Contains the GP created by a user-defined GP package
Details
This is effectively a dummy wrapper based on the wrapper for the mlegp package (see WrappedmlegpGP). It contains a basic implementation of the wrapper. The vignette offers a tutorial on how to change this wrapper for the new GP package.
Public fields
gp
The mlegp GP object (mlegp::mlegp in the
mlegp
manual)X_buffer
Buffer matrix to collect x points until first GP can be trained
y_buffer
Buffer vector to collect y points until first GP can be trained
y_var_buffer
Buffer vector to collect variance of y points until first GP can be trained
add_y_var
Small additional variance used to keep the covariance matrix condition number under control
n_points_train_limit
Number of points needed before we can create the GP
n_points
The number of collected points belonging to this GP
x_dim
Dimensionality of input points
gp_control
A list of GP implementation-specific options, passed directly to the wrapped GP implementation
init_covpars
The initial covariance parameters when training the mlegp GP object in self@gp
estimate_covpars
If TRUE, the parameters are estimated by the package. Otherwise, the parameters from init_covpars are taken
retrain_buffer_length
Only retrain after this many new points have been added to the buffer
retrain_buffer_counter
Counter for the number of new points added since last retraining
add_buffer_in_prediction
If TRUE, points in the data buffers are added to the GP before prediction. They are added into a temporarily created GP which contains the not yet included points. The GP in the node is not yet updated.
X_shared
Matrix with x points that this GP shares with the GP in the sibling node
y_shared
Vector of y points that this GP shares with the GP in the sibling node
y_var_shared
Vector of y_var points that this GP shares with the GP in the sibling node
n_shared_points
The number of own points shared with the GP in the sibling node
Methods
Public methods
Method new()
Create a new WrappedmlegpGP object
Usage
WrappedGP$new( X, y, y_var, gp_control, init_covpars, retrain_buffer_length, add_buffer_in_prediction, estimate_covpars = TRUE, X_shared = NULL, y_shared = NULL, y_var_shared = NULL )
Arguments
X
Input data matrix with x_dim columns and at maximum Nbar rows. Is used to create the first iteration of the local GP.
y
Value of target variable at input point x; has to be a one-dimensional matrix or a vector; any further columns will be ignored
y_var
Variance of the target variable; has to be a one-dimensional matrix or vector
gp_control
A list of GP implementation-specific options, passed directly to the wrapped GP implementation
init_covpars
Initial covariance parameters of the local GP
retrain_buffer_length
Only retrain when the number of buffer points or collected points exceeds this value
add_buffer_in_prediction
If TRUE, points in the data buffers are added to the GP before prediction. They are added into a temporarily created GP which contains the not yet included points. The GP in the node is not yet updated.
estimate_covpars
If TRUE, the parameters are estimated by the package. Otherwise, the parameters from init_covpars are taken
X_shared
Matrix with x points that this GP shares with the GP in the sibling node
y_shared
Vector of y points that this GP shares with the GP in the sibling node
y_var_shared
Vector of y_var points that this GP shares with the GP in the sibling node
Returns
A new WrappedGP object. Besides the local GP, information on the shared points and those stored in the buffer are collected. For more information on the GP, consult the respective met in the GP package.
Method update_init_covpars()
Stores the initial covariance parameters (length-scales, standard deviation and trend coefficients) of the GP in the field init_covpars
Usage
WrappedGP$update_init_covpars()
Method get_lengthscales()
Retrieves the length-scales of the kernel of the local GP
Usage
WrappedGP$get_lengthscales()
Method get_X_data()
Retrieves the design matrix X
Usage
WrappedGP$get_X_data(include_shared = FALSE)
Arguments
include_shared
If TRUE, shared points between this GP and its sibling GP are included
Method get_y_data()
Retrieves the response
Usage
WrappedGP$get_y_data(include_shared = FALSE)
Arguments
include_shared
If TRUE, shared points between this GP and its sibling GP are included
Method get_y_var_data()
Retrieves the individual variances from the response
Usage
WrappedGP$get_y_var_data(include_shared = FALSE)
Arguments
include_shared
If TRUE, shared points between this GP and its sibling GP are included
Method get_cov_mat()
Retrieves the covariance matrix
Usage
WrappedGP$get_cov_mat()
Returns
the covariance matrix
Method update_add_y_var()
Method for updating add_y_var based on a bound for the covariance matrix condition number, based on this paper, Section 5.4
Usage
WrappedGP$update_add_y_var(max_cond_num)
Arguments
max_cond_num
Max allowed condition number
Method store_point()
Stores a new point into the respective buffer method
Usage
WrappedGP$store_point(x, y, y_var, shared = FALSE, remove_shared = TRUE)
Arguments
x
Single input data point from the data stream; has to be a vector or row matrix with length equal to x_dim
y
Value of target variable at input point x; has to be a one-dimensional matrix or a vector; any further columns will be ignored
y_var
Variance of the target variable; has to be a one-dimensional matrix or vector
shared
If TRUE, this point is shared between this GP and its sibling GP
remove_shared
If TRUE, the last of the shared points is removed
Method delete_buffers()
Method for clearing the buffers
Usage
WrappedGP$delete_buffers()
Method delete_gp()
Method to delete the GP object in self$gp
Usage
WrappedGP$delete_gp()
Method call_create_gp()
Method for calling the 'mlegp' function in mlegp to create a GP object, stored in self$gp
Usage
WrappedGP$call_create_gp(X, y, y_var)
Arguments
X
Input data matrix with x_dim columns and at maximum Nbar rows for the local GP.
y
Value of target variable at input point x; has to be a one-dimensional matrix or a vector; any further columns will be ignored
y_var
Variance of the target variable; has to be a one-dimensional matrix or vector
Returns
TRUE
Method call_predict()
Method for calling the 'predict' function in mlegp
Usage
WrappedGP$call_predict(x, use_gp = NULL)
Arguments
x
Single data point for which the predicted mean (and standard deviation) is computed; has to be a vector with length equal to x_dim
use_gp
Optional user-defined GP which is evaluated instead of the local GP
Returns
The predictions for x from the specified GP, by default the local GP. The output needs to be a list with fields mean and sd for the prediction and prediction error, respectively.
Method train()
Method for (re)creating / (re)training the GP
Usage
WrappedGP$train(do_buffer_check = TRUE)
Arguments
do_buffer_check
If TRUE, only train the GP if the number of stored points is larger than retrain_buffer_length
Returns
TRUE if training was performed, otherwise FALSE
Method predict()
Method for prediction
Usage
WrappedGP$predict(x, return_std = TRUE)
Arguments
x
Single data point for which the predicted mean (and standard deviation) is computed; has to be a vector or row matrix with length equal to x_dim
return_std
If TRUE, the standard error is returned in addition to the prediction
Returns
Prediction for input point x
Method clone()
The objects of this class are cloneable with this method.
Usage
WrappedGP$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.