krbf | R Documentation |
Building Gram matrices for different kernels (e.g. Scholkopf & Smola 2002).
- radial basis: exp(-gamma * |x - y|^2)
- polynomial: (gamma * x' * y + coef0)^degree
- sigmoid: tanh(gamma * x' * y + coef0)
krbf(X, Y = NULL, gamma = 1)
kpol(X, Y = NULL, degree = 1, gamma = 1, coef0 = 0)
ktanh(X, Y = NULL, gamma = 1, coef0 = 0)
X |
Dataset ( |
Y |
Dataset ( |
gamma |
See the code. |
degree |
See the code. |
coef0 |
See the code. |
See the examples.
Scholkopf, B., Smola, A.J., 2002. Learning with kernels: support vector machines, regularization, optimization, and beyond, Adaptive computation and machine learning. MIT Press, Cambridge, Mass.
n <- 5 ; p <- 3
Xtrain <- matrix(rnorm(n * p), ncol = p)
Xtest <- Xtrain[1:2, , drop = FALSE]
gamma <- .8
krbf(Xtrain, gamma = gamma)
krbf(Xtest, Xtrain, gamma = gamma)
exp(-.5 * euclsq(Xtest, Xtrain) / gamma^2)
kpol(Xtrain, degree = 2, gamma = .5, coef0 = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.