2

Lately I've worked with kernlab library in R-statistical software. In specific, I use the ksvm function to identify patterns. I'm trying to implement a new kernel in SVM, my code is:

<gnndot<-function (sigma = 1, degree=2) 
{
    rval <- function(x, y = NULL) {
        return(exp(-sigma * ( sqrt(-(round(2 * crossprod(x, y) - crossprod(x) -     crossprod(y), 9)))^degree ) ))
        }
}

library(mvtnorm)
library(kernlab)
x <- rmvnorm(n=500, mean=c(1,1.5,2,2.5,3), sigma=diag(5))
class<-rep(c("ONE","TWO","THREE","FOUR","FIVE"),each=100)
ksvm(x,class,type="C-svc",kernel ="gnndot",kpar=list(sigma=0.05,degree=1.5),C=600,cross=5)>

The result that I got is: Error in match.arg(kernel, c("rbfdot", "polydot", "tanhdot", "vanilladot", : 'arg' should be one of “rbfdot”, “polydot”, “tanhdot”, “vanilladot”, “laplacedot”, “besseldot”, “anovadot”, “splinedot”, “matrix” This is, I must define this "user-defined" kernel as one of the already designed kernels. Is it possible to use the kernel here defined (gnndot) as one usable by the function ksvm?

  • Yes it is, see for example [here](http://stackoverflow.com/questions/12085454/r-svm-performance-using-custom-kernel-user-defined-kernel-is-not-working-in-k). – Vincent Guillemot Aug 04 '14 at 16:05
  • Cheers Vicent. My problem is defining the `gnndot` function and also, I would like to control the values of `sigma` and `degree` by mean of the `kpar` command in the ksvm function and this is not clear for me. Do you know if it is possible to do so? – Hector De la Torre Aug 04 '14 at 16:44

0 Answers0