1\name{kernelMatrix}
2\alias{kernelMatrix}
3\alias{kernelMult}
4\alias{kernelPol}
5\alias{kernelFast}
6\alias{kernelPol,kernel-method}
7\alias{kernelMatrix,kernel-method}
8\alias{kernelMult,kernel-method}
9\alias{kernelFast,kernel-method}
10\alias{kernelMatrix,rbfkernel-method}
11\alias{kernelMatrix,polykernel-method}
12\alias{kernelMatrix,vanillakernel-method}
13\alias{kernelMatrix,tanhkernel-method}
14\alias{kernelMatrix,laplacekernel-method}
15\alias{kernelMatrix,anovakernel-method}
16\alias{kernelMatrix,splinekernel-method}
17\alias{kernelMatrix,besselkernel-method}
18\alias{kernelMatrix,stringkernel-method}
19\alias{kernelMult,rbfkernel,ANY-method}
20\alias{kernelMult,splinekernel,ANY-method}
21\alias{kernelMult,polykernel,ANY-method}
22\alias{kernelMult,tanhkernel,ANY-method}
23\alias{kernelMult,laplacekernel,ANY-method}
24\alias{kernelMult,besselkernel,ANY-method}
25\alias{kernelMult,anovakernel,ANY-method}
26\alias{kernelMult,vanillakernel,ANY-method}
27\alias{kernelMult,character,kernelMatrix-method}
28\alias{kernelMult,stringkernel,ANY-method}
29\alias{kernelPol,rbfkernel-method}
30\alias{kernelPol,splinekernel-method}
31\alias{kernelPol,polykernel-method}
32\alias{kernelPol,tanhkernel-method}
33\alias{kernelPol,vanillakernel-method}
34\alias{kernelPol,anovakernel-method}
35\alias{kernelPol,besselkernel-method}
36\alias{kernelPol,laplacekernel-method}
37\alias{kernelPol,stringkernel-method}
38\alias{kernelFast,rbfkernel-method}
39\alias{kernelFast,splinekernel-method}
40\alias{kernelFast,polykernel-method}
41\alias{kernelFast,tanhkernel-method}
42\alias{kernelFast,vanillakernel-method}
43\alias{kernelFast,anovakernel-method}
44\alias{kernelFast,besselkernel-method}
45\alias{kernelFast,laplacekernel-method}
46\alias{kernelFast,stringkernel-method}
47\alias{kernelFast,splinekernel-method}
48
49\title{Kernel Matrix functions}
50\description{
51  \code{kernelMatrix} calculates the kernel matrix \eqn{K_{ij} = k(x_i,x_j)} or \eqn{K_{ij} =
52    k(x_i,y_j)}.\cr
53  \code{kernelPol} computes the quadratic kernel expression  \eqn{H = z_i z_j
54    k(x_i,x_j)}, \eqn{H = z_i k_j k(x_i,y_j)}.\cr
55    \code{kernelMult} calculates the kernel expansion \eqn{f(x_i) =
56      \sum_{i=1}^m z_i  k(x_i,x_j)}\cr
57    \code{kernelFast} computes the kernel matrix, identical
58    to \code{kernelMatrix}, except that it also requires the squared
59    norm of the first argument as additional input, useful in iterative
60    kernel matrix calculations.
61 }
62\usage{
63\S4method{kernelMatrix}{kernel}(kernel, x, y = NULL)
64
65\S4method{kernelPol}{kernel}(kernel, x, y = NULL, z, k = NULL)
66
67\S4method{kernelMult}{kernel}(kernel, x, y = NULL, z, blocksize = 256)
68
69\S4method{kernelFast}{kernel}(kernel, x, y, a)
70}
71
72\arguments{
73  \item{kernel}{the kernel function to be used to calculate the kernel
74    matrix.
75  This has to be a function of class \code{kernel}, i.e. which can be
76  generated either one of the build in
77  kernel generating functions (e.g., \code{rbfdot} etc.) or a user defined
78  function of class \code{kernel} taking two vector arguments and returning a scalar.}
79  \item{x}{a data matrix to be used to calculate the kernel matrix, or a
80  list of vector when a \code{stringkernel} is used}
81  \item{y}{second data matrix to calculate the kernel matrix, or a
82  list of vector when a \code{stringkernel} is used}
83  \item{z}{a suitable vector or matrix}
84  \item{k}{a suitable vector or matrix}
85  \item{a}{the squared norm of \code{x}, e.g., \code{rowSums(x^2)}}
86  \item{blocksize}{the kernel expansion computations are done block wise
87    to avoid storing the kernel matrix into memory. \code{blocksize}
88    defines the size of the computational blocks.}
89}
90\details{
91  Common functions used during kernel based computations.\cr
92  The \code{kernel} parameter can be set to any function, of class
93  kernel, which computes the inner product in feature space between two
94  vector arguments. \pkg{kernlab} provides the most popular kernel functions
95  which can be initialized by using the following
96  functions:
97    \itemize{
98      \item \code{rbfdot} Radial Basis kernel function
99      \item \code{polydot} Polynomial kernel function
100      \item \code{vanilladot} Linear kernel function
101      \item \code{tanhdot} Hyperbolic tangent kernel function
102      \item \code{laplacedot} Laplacian kernel function
103      \item \code{besseldot} Bessel kernel function
104      \item \code{anovadot} ANOVA RBF kernel function
105      \item \code{splinedot} the Spline kernel
106    }  (see example.)
107
108    \code{kernelFast} is mainly used in situations where columns of the
109    kernel matrix are computed per invocation. In these cases,
110    evaluating the norm of each row-entry over and over again would
111    cause significant computational overhead.
112  }
113
114\value{
115  \code{kernelMatrix} returns a symmetric diagonal semi-definite matrix.\cr
116  \code{kernelPol} returns a matrix.\cr
117  \code{kernelMult} usually returns a one-column matrix.
118}
119\author{Alexandros Karatzoglou \cr
120\email{alexandros.karatzoglou@ci.tuwien.ac.at}}
121
122
123\seealso{\code{\link{rbfdot}}, \code{\link{polydot}},
124  \code{\link{tanhdot}}, \code{\link{vanilladot}}}
125
126\examples{
127## use the spam data
128data(spam)
129dt <- as.matrix(spam[c(10:20,3000:3010),-58])
130
131## initialize kernel function
132rbf <- rbfdot(sigma = 0.05)
133rbf
134
135## calculate kernel matrix
136kernelMatrix(rbf, dt)
137
138yt <- as.matrix(as.integer(spam[c(10:20,3000:3010),58]))
139yt[yt==2] <- -1
140
141## calculate the quadratic kernel expression
142kernelPol(rbf, dt, ,yt)
143
144## calculate the kernel expansion
145kernelMult(rbf, dt, ,yt)
146}
147\keyword{algebra}
148\keyword{array}
149