最近我在R-statistics软件中使用kernlab
库。具体来说,我使用ksvm
函数来识别模式。我正在尝试在SVM中实现一个新内核,我的代码是:
<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)>
我得到的结果是:Error in match.arg(kernel, c("rbfdot", "polydot", "tanhdot", "vanilladot", : 'arg' should be one of “rbfdot”, “polydot”, “tanhdot”, “vanilladot”, “laplacedot”, “besseldot”, “anovadot”, “splinedot”, “matrix”
这是,我必须将这个“用户定义的”内核定义为已经设计的内核之一。是否可以将此处定义的内核(gnndot
)用作函数ksvm
可用的内核?