Skip to contents

Extract kernel parameters

Usage

kernel_parameters(kernel, flatten = FALSE)

Arguments

kernel

A Gaussian-process kernel specification.

flatten

If FALSE, return a nested list matching the kernel structure. If TRUE, return a named numeric vector with stable parameter paths suitable for optimization. Vector parameters use indexed names such as length_scale[1].

Value

A nested list or named numeric vector.

Details

Flat parameter names encode the position of each nested kernel. Scalar parameters use paths such as kernel1.variance; vector-valued ARD parameters use paths such as kernel1.length_scale[1] and kernel1.length_scale[2]. These names remain stable when parameter values are updated and can be passed directly to optimization routines.

A large ARD length scale means covariance changes slowly along that input dimension, while a small value means covariance changes more rapidly. This is a model sensitivity parameterization and should not be interpreted as a causal importance measure.

Stability

Stable: from version 1.0.0 this interface changes incompatibly only in a major release, after a deprecation period. Results and options that concern an experimental model class, kernel, or argument follow that interface's tier. See gaussianprocesses-package for the policy.

Examples

kernel <- sum_kernel(
  rbf_kernel(length_scale = c(1, 2)),
  white_noise_kernel(variance = 0.1)
)

str(kernel_parameters(kernel))
#> List of 2
#>  $ kernel1:List of 2
#>   ..$ variance    : num 1
#>   ..$ length_scale: num [1:2] 1 2
#>  $ kernel2:List of 1
#>   ..$ variance: num 0.1
kernel_parameters(kernel, flatten = TRUE)
#>        kernel1.variance kernel1.length_scale[1] kernel1.length_scale[2] 
#>                     1.0                     1.0                     2.0 
#>        kernel2.variance 
#>                     0.1