gaussKern: Gaussian kernel

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/gaussKern.R

Description

Calculates Gaussian kernel: k(x,x') = \exp(-θ \|x - x'\|^2)

Usage

1
gaussKern(x, newdata = x, theta = NULL)

Arguments

x

a data matrix.

newdata

optional second data matrix.

theta

the inverse kernel bandwidth parameter. If NULL a default value is used θ = 1/max(\|x - x'\|^2).

Details

Also known as the radial basis kernel function, see rbfdot (in package kernlab)

Value

Returns a list containing the following components:

K

a Gaussian kernel matrix of class "kern".

theta

the inverse kernel bandwidth parameter.

Author(s)

K. Domijan

See Also

kPCA bkpc kernelMatrix (in package kernlab)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
data(iris)

testset <- sample(1:150,20)
train <- as.matrix(iris[-testset ,-5])
test <- as.matrix(iris[testset ,-5])


# make training set kernel
gk <- gaussKern(train)
Ktrain <- gk$K

image(Ktrain)

# make testing set kernel
gk2 <- gaussKern(train, test, gk$theta) 
Kest <- gk2$K

BKPC documentation built on May 1, 2019, 9:10 p.m.