kernel.matrix {KSPM} | R Documentation |
These functions transform a n \times p
matrix into a n \times n
kernel matrix.
kernel.matrix(Z, whichkernel, rho = NULL, gamma = NULL, d = NULL)
Z |
a |
whichkernel |
kernel function |
gamma , rho , d |
kernel hyperparameters (see details) |
Given a n \times p
matrix, this function returns a n \times n
matrix where each cell represents the similarity between two samples defined by two p-
dimensional vectors x
and y
,
the Gaussian kernel is defined as k(x,y) = exp\left(-\frac{\parallel x-y \parallel^2}{\rho}\right)
where \parallel x-y \parallel
is the Euclidean distance between x
and y
and \rho > 0
is the bandwidth of the kernel,
the linear kernel is defined as k(x,y) = x^Ty
,
the polynomial kernel is defined as k(x,y) = (\rho x^Ty + \gamma)^d
with \rho > 0
, d
is the polynomial order. Of note, a linear kernel is a polynomial kernel with \rho = d = 1
and \gamma = 0
,
the sigmoid kernel is defined as k(x,y) = tanh(\rho x^Ty + \gamma)
which is similar to the sigmoid function in logistic regression,
the inverse quadratic function defined as k(x,y) = \frac{1}{\sqrt{\parallel x-y \parallel^2 + \gamma}}
with \gamma > 0
,
the equality kernel defined as k(x,y) = \left\lbrace \begin{array}{ll} 1 & if x = y \\ 0 & otherwise \end{array}\right.
.
A n \times n
matrix.
Catherine Schramm, Aurelie Labbe, Celia Greenwood
kernel.gaussian, kernel.linear, kernel.polynomial, kernel.equality, kernel.sigmoid, kernel.inverse.quadratic.