Skip to contents

Runs both models with identical fixed kernel and noise parameters, then compares retained model size, elapsed fitting/prediction time, posterior mean RMSE, and latent-variance MAE. The exact GP is treated as the numerical reference, not as ground truth.

Usage

benchmark_sparse_gp(
  x,
  y,
  kernel,
  n_inducing,
  prediction_x = x,
  noise_variance = 1e-06,
  mean = zero_mean(),
  selection = c("farthest", "quantile", "variance"),
  observation_noise_variance = NULL
)

Arguments

x

Numeric vector or matrix of training inputs.

y

Numeric response vector.

kernel

Fixed kernel specification shared by both models.

n_inducing

Number of inducing points for FITC.

prediction_x

Optional prediction inputs; defaults to x.

noise_variance

Non-negative observation-noise variance: a scalar, or one value per training observation. Both models use the same noise.

mean

Mean specification shared by both models.

selection

Inducing-point selection method.

observation_noise_variance

Optional noise variance at prediction_x, passed to both predictions. It is required when noise_variance has one value per observation, as in predict_gp().

Value

A list containing a comparison data frame and both prediction objects.

Details

The benchmark reports retained R object size, not peak process memory. Elapsed timings are simple wall-clock measurements intended for local comparison, not publication-grade benchmarking.

Stability

Experimental: this interface may change in a minor release, and every change is listed in NEWS. See gaussianprocesses-package for the policy.

Examples

x <- seq(-3, 3, length.out = 200)
y <- sin(x) + 0.1 * cos(7 * x)

benchmark <- benchmark_sparse_gp(
  x,
  y,
  kernel = rbf_kernel(length_scale = 0.8),
  n_inducing = 15,
  noise_variance = 0.01
)
benchmark$comparison
#>   model n_training n_inducing fit_elapsed_seconds predict_elapsed_seconds
#> 1 exact        200        200               0.007                   0.003
#> 2  FITC        200         15               0.003                   0.001
#>   retained_model_bytes posterior_mean_rmse_vs_exact
#> 1               335952                   0.00000000
#> 2                56240                   0.00236342
#>   latent_variance_mae_vs_exact
#> 1                 0.000000e+00
#> 2                 4.390554e-05