kernels.gen: Generate both training and test kernel matrices

Description Usage Arguments Value Examples

View source: R/kernel.gen.R

Description

This function creates gramm matrix for traning set baed upon several types of kernel and specified hyper paremeters. This function is essentially a wrappper functions that combines gramm and grammpred. Additionally this function divides each kernel matrix by it's trace, which is a common transformation used in MKL.

Usage

1
kernels.gen(data, train.samples, kernels, degree, scale, sigma)

Arguments

data

List of data matrices

train.samples

Vector of indices that will be used as training samples

kernels

Character vector of kernel types

degree

Degree of polynomial kernel matrix

scale

Leading coefficient on the polynomial kernel

sigma

Hyperparameter for the radial basis kernel

Value

K.train Gramm matricesfor training data

K.test Gramm matrices for test data

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
library(kernlab)
data(benchmark.data)
example.data=benchmark.data[[1]]
#Dividing the samples into a train set and test set.
training.samples=sample(1:dim(example.data)[1],floor(0.7*dim(example.data)[1]),replace=FALSE)
#Specifying the type and hyperparameters for each kernel.
kernels=c('linear',rep('radial',3))
degree=rep(0,4)
scale=rep(0,4)
sigma=c(0,2^seq(-3:0))
kernels.gen(example.data[,1:2], training.samples, kernels, degree, scale, sigma)

cwilso6/RMKL documentation built on May 18, 2021, 9:58 a.m.