kernelMatrix calculates the kernel matrix Kij=k(xi,xj) or c("Kij=\n", "k(xi,yj)").
kernelPol computes the quadratic kernel expression c("H=zizj\n", "k(xi,xj)"), H=zikjk(xi,yj).
kernelMult calculates the kernel expansion c("f(xi)=\n", "sumi=1mzik(xi,xj)")
kernelFast computes the kernel matrix, identical to kernelMatrix, except that it also requires the squared norm of the first argument as additional input, useful in iterative kernel matrix calculations.
## S4 method for signature 'kernel'kernelMatrix(kernel, x, y =NULL)## S4 method for signature 'kernel'kernelPol(kernel, x, y =NULL, z, k =NULL)## S4 method for signature 'kernel'kernelMult(kernel, x, y =NULL, z, blocksize =256)## S4 method for signature 'kernel'kernelFast(kernel, x, y, a)
Arguments
kernel: the kernel function to be used to calculate the kernel matrix. This has to be a function of class kernel, i.e. which can be generated either one of the build in kernel generating functions (e.g., rbfdot etc.) or a user defined function of class kernel taking two vector arguments and returning a scalar.
x: a data matrix to be used to calculate the kernel matrix, or a list of vector when a stringkernel is used
y: second data matrix to calculate the kernel matrix, or a list of vector when a stringkernel is used
z: a suitable vector or matrix
k: a suitable vector or matrix
a: the squared norm of x, e.g., rowSums(x^2)
blocksize: the kernel expansion computations are done block wise to avoid storing the kernel matrix into memory. blocksize
defines the size of the computational blocks.
Details
Common functions used during kernel based computations.
The kernel parameter can be set to any function, of class kernel, which computes the inner product in feature space between two vector arguments. kernlab provides the most popular kernel functions which can be initialized by using the following functions:
rbfdot Radial Basis kernel function
polydot Polynomial kernel function
vanilladot Linear kernel function
tanhdot Hyperbolic tangent kernel function
laplacedot Laplacian kernel function
besseldot Bessel kernel function
anovadot ANOVA RBF kernel function
splinedot the Spline kernel
(see example.)
kernelFast is mainly used in situations where columns of the kernel matrix are computed per invocation. In these cases, evaluating the norm of each row-entry over and over again would cause significant computational overhead.
Returns
kernelMatrix returns a symmetric diagonal semi-definite matrix.