0

我想知道当我使用 ksvm 时如何找出sigma的最佳值(我的数据集有 21 个分类和数值变量,有 1400 个观察值)这是我的代码:

rbf <- rbfdot(sigma = 0.05)
model <- ksvm(target~.,data = train,prob.model = TRUE,kernel = rbf)
p <- predict(model,test,type="probabilities")
4

2 回答 2

1

我同意这kpar="automatic"可能会有所帮助,但这仅适用于一些无监督的启发式方法,并不一定会优化分类精度的参数。实现后者的唯一方法是编写一个将网格搜索与交叉验证结合使用的包装器。如果您不想自己编写,mlr 包(函数tuneParams())可以为您完成。e1071 包(包括一个到 LIBSVM 的接口)也提供了一个tune()做同样事情的函数。

干杯,UBod

于 2014-02-24T15:40:04.293 回答
0

ksvm 为您找出最佳的 sigma 值。我在写作

训练 svm 向量

ksvm_model<- ksvm(x=train,y=y,scaled=TRUE,type="nu-svr",kernel="rbfdot", kpar="automatic", prob.model=TRUE,class.weights=NULL,cache=100,cross=5);
#summary(ksvm_model);
# train and test the model over the test data 
next_y<-predict(ksvm_model,test_mat,type="response");

"kpar="automatic"" 会为您做到这一点。

只需检查一下。

于 2013-03-27T18:40:33.723 回答