我正在试验高斯过程模型,特别是kernlab R包中的实现。我发现模型在用线性内核切除时会挂起。分析显示它正忙于通过运算符"%*%"进行矩阵乘法运算。下面给出了一个可重复的例子:
data(iris)
#this doesn't hang
test <- kernlab::gausspr(Species~.,data=iris,type="classification",kernel="rbfdot")
#this hangs with message "Setting default kernel parameters"
test <- kernlab::gausspr(Species~.,data=iris,type="classification",kernel="vanilladot")
#this also hangs
test <- kernlab::gausspr(Species~.,data=iris,type="classification",kernel="polydot", kpar=list(degree=1))
#this doesn't hang
test <- kernlab::gausspr(Species~.,data=iris,type="classification",kernel="polydot", kpar=list(degree=2))
知道这里发生了什么吗?非常感谢!
您需要为每个内核类型指定不同的调优超参数kpar
。默认选项为kpar=list(sigma=0.1),仅适用于Gaussian内核。
每个内核kpar
的超参数列表如下:
sigma
逆核宽度。
多项式核">polydot"的degree, scale, offset
。
双曲正切核函数">tanhdot"的scale, offset
。
贝塞尔核">besseldot"的sigma, order, degree
。
方差分析核">anovadot"的sigma, degree
。
如果您想更好地理解原因,请查看此pdf中的内核函数,见第9页。
然而,对于简单的LINERAL内核来说,情况有点棘手,即kernel=vanilladot。没有要指定的超参数。我试过kpar=NA,但没有用。我找到了一种方法来获得线性内核的结果,使用具有特殊调整的多项式:
test <- kernlab::gausspr(Species~.,data=iris,type="classification",
kernel="polydot", kpar=list(degree =1, scale =1, offset =0))