generate_kernel: Generating A Single Kernel

Description Usage Arguments Details Value Author(s) References Examples

View source: R/generate_kernel.R

Description

Generate kernels for the kernel library.

Usage

1
generate_kernel(method = "rbf", l = 1, p = 2, sigma = 1)

Arguments

method

(character) A character string indicating which kernel is to be computed.

l

(numeric) A numeric number indicating the hyperparameter (flexibility) of a specific kernel.

p

(integer) For polynomial, p is the power; for matern, v = p + 1 / 2; for rational, alpha = p.

sigma

(numeric) The covariance coefficient for neural network kernel.

Details

There are seven kinds of kernel available here. For convenience, we define r=\mid x-x'\mid.

Gaussian RBF Kernels

k_{SE}(r)=exp\Big(-\frac{r^2}{2l^2}\Big)

Matern Kernels

k_{Matern}(r)=\frac{2^{1-ν}}{Γ(ν)}\Big(\frac{√{2ν r}}{l}\Big)^ν K_ν \Big(\frac{√{2ν r}}{l}\Big)

Rational Quadratic Kernels

k_{RQ}(r)=\Big(1+\frac{r^2}{2α l^2}\Big)^{-α}

Polynomial Kernels

k(x, x')=(x \cdot x')^p

We have intercept kernel when p=0, and linear kernel when p=1.

Neural Network Kernels

k_{NN}(x, x')=\frac{2}{π}sin^{-1}\Big(\frac{2σ \tilde{x}^T \tilde{x}'}{√{(1+2σ \tilde{x}^T \tilde{x})(1+2σ \tilde{x}'^T \tilde{x}')}}\Big)

where \tilde{x} is the vector x prepending with 1.

Value

kern

(function) A function indicating the generated kernel.

Author(s)

Wenying Deng

References

The MIT Press. Gaussian Processes for Machine Learning, 2006.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
kern_par <- data.frame(method = c("rbf", "polynomial", "matern"),
l = c(.5, 1, 1.5), p = 1:3, sigma = rep(1, 3), stringsAsFactors = FALSE)

kern_func_list <- list()
for (j in 1:nrow(kern_par)) {
  kern_func_list[[j]] <- generate_kernel(kern_par[j, ]$method,
                                         kern_par[j, ]$l,
                                         kern_par[j, ]$p, 
                                         kern_par[j, ]$sigma)
}

CVEK documentation built on Jan. 8, 2021, 5:42 p.m.