library(e1071)
##设定循环必要的参数
control<-tune.control(random=FALSE,nrepeat=1,repeat.aggregate=min,sampling="cross",
cross=94,best.model=TRUE,performances=TRUE,error.fun=NULL)
##设定gamma,cost的寻找范围,及svm的其它参数。
##结果会给出你的参数中最好的一组参数。(最好的意义与你设定的评价办法相关)
obj<-tune(method="svm",train.x=t(es2),train.y=negType,
range=list(gamma=seq(from=0.001,to=0.01,by=0.001),
cost=seq(from=1,to=10,by=1)),
kernel="sigmoid",tunecontrol=control)
|