Learn R Programming

RMKL (version 1.0)

kernels.gen: Generate both training and test kernel matrices

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

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

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

Run the code above in your browser using DataLab