Learn R Programming

BKPC (version 1.0.1)

gaussKern: Gaussian kernel

Description

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

Usage

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 \(\theta = 1/max(\|x - x'\|^2)\).

Value

Returns a list containing the following components:

K

a Gaussian kernel matrix of class "kern".

theta

the inverse kernel bandwidth parameter.

Details

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

See Also

kPCA bkpc kernelMatrix (in package kernlab)

Examples

Run this code
# NOT RUN {
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

# }

Run the code above in your browser using DataLab