| Title: | Fast, composable Gaussian Processes in R. |
|---|---|
| Description: | Fast, composable Gaussian Processes in R. |
| Authors: | Beniamino Green [aut, cre] (ORCID: <https://orcid.org/0009-0006-4501-597X>) |
| Maintainer: | Beniamino Green <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.0.0.9000 |
| Built: | 2026-05-25 06:14:10 UTC |
| Source: | https://github.com/beniaminogreen/zoomergp |
Fit a Gaussian process in R
gaussian_process( form, data, sparse = F, n_points = 5, training_method = "bfgs", noise = T )gaussian_process( form, data, sparse = F, n_points = 5, training_method = "bfgs", noise = T )
form |
the regression formula for the gaussian process. The left-hand-side gives determines outcome you are fitting the GP to, and the right-hand side gives the kernel specification. |
data |
the dataframe from which to source regression data. |
sparse |
a boolean indicating whether to use the projected process approximation to speed up training. Recommended for N>500. |
n_points |
The number of inducing points used for the projected process approximation. Defaults to 5. If set too large, may cause numerical stability issues when calculating the gradient of the marginal likelihood. |
training_method |
one of 'bfgs', 'cg' (conjugate gradient), 'rgenoud' (genetic optimization using derivatives), or "coin" (coin betting). The method used to optimize the marginal likelihood (default BFGS). |
noise |
whether to fit a GP assuming function values are observed with noise (default TRUE). Setting FALSE is only available when sparse = F. |
library(tibble) library(ggplot2) n <- 400 data <- tibble( x = runif(n), y = runif(n), z = x^2 + rnorm(n, 0,.1) ) gp_model <- gaussian_process(z ~ rbf(x,y), data = data) data$predictions <- predict(gp_model)[,1] ggplot(data, aes(x=x)) + geom_point(aes(y= z)) + geom_line(aes(y=predictions))library(tibble) library(ggplot2) n <- 400 data <- tibble( x = runif(n), y = runif(n), z = x^2 + rnorm(n, 0,.1) ) gp_model <- gaussian_process(z ~ rbf(x,y), data = data) data$predictions <- predict(gp_model)[,1] ggplot(data, aes(x=x)) + geom_point(aes(y= z)) + geom_line(aes(y=predictions))
Fit a logistic Gaussian process in R for a binary outcome
logistic_gaussian_process( formula, data, sparse = T, n_points = 10, n_particles = 10, n_iter = 2000 )logistic_gaussian_process( formula, data, sparse = T, n_points = 10, n_particles = 10, n_iter = 2000 )
data |
the dataframe from which to source regression data. |
sparse |
a Boolean indicating whether to use the projected process approximation to speed up training. Recommended for N>100. |
n_points |
The number of inducing points used for the projected process approximation. Defaults to 5. If set too large, may cause numerical stability issues when calculating the gradient of the marginal likelihood. |
n_particles |
number of particles to be used in the stein variational gradient descent simulation |
form |
the regression formula for the Gaussian process. The left-hand-side gives determines outcome you are fitting the GP to, and the right-hand side gives the kernel specification. |
Plot Gaussian Process Fit
## S3 method for class 'gaussian_process' plot(x, col = 1, add_points = T, ...)## S3 method for class 'gaussian_process' plot(x, col = 1, add_points = T, ...)
x |
Gaussian Process object |
col |
column name for the predictor you want to plot. All other predictors are set to their medians |
add_points |
whether to plot datapoints in the background |
... |
additional arguments (ignored) |
Predict Function Values at a Test Point
## S3 method for class 'gaussian_process' predict(object, newdata = NULL, kernel_str = NA, ...)## S3 method for class 'gaussian_process' predict(object, newdata = NULL, kernel_str = NA, ...)
object |
An object for which predictions are desired. |
newdata |
a new data set to generate predictions for. Must have all of the predictor columns of the original data set or an error will be returned. |
kernel_str |
the label of the kernel you would like to extract predictions for. This can be useful if you are (for example) attempting to isolate a specific signal from a data set such as a periodic component from a time series. Use the print method of the Gaussian process to determine the labels for the individual kernels. |
... |
additional arguments (ignored) |
Print information about a Gaussian Process
## S3 method for class 'gaussian_process' print(x, ...)## S3 method for class 'gaussian_process' print(x, ...)
x |
Gaussian Process object |
... |
additional arguments (ignored) |
Get Residuals for Gaussian Process
## S3 method for class 'gaussian_process' residuals(object, ...)## S3 method for class 'gaussian_process' residuals(object, ...)
object |
An object for which residuals are desired. |
... |
additional arguments (ignored) |