[英]gausspr function from R package kernlab hangs on linear kernel
我正在試驗高斯過程模型,尤其是在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) ,僅適用於高斯內核。
每個內核kpar
的超參數列表如下:
徑向基礎內核函數“ rbfdot ”和拉普拉斯內核“ laplacedot ”的sigma
逆內核寬度。
多項式內核“ polydot ”的degree, scale, offset
位數 degree, scale, offset
。
scale, offset
雙曲線正切核函數“ tanhdot ”的scale, offset
。
貝塞爾內核“ besseldot ”的sigma, order, degree
。
sigma, degree
方差分析內核“ anovadot ”的度數 。
如果您想更好地理解原因,請在第9頁的pdf中檢查內核功能。
但是,對於簡單的LINEAR內核而言,事情有些棘手,即kernel = vanilladot 。 沒有要指定的超參數。 我嘗試了kpar = NA,但是沒有用。 我想出了一種使用多項式進行特殊調整來獲得LINEAR內核結果的方法:
test <- kernlab::gausspr(Species~.,data=iris,type="classification",
kernel="polydot", kpar=list(degree =1, scale =1, offset =0))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.