在R中使用SVM优化SVM参数时出错

时间:2019-04-21 22:44:24

标签: r svm particle-swarm

我正在尝试使用R中的PSO为回归问题优化SVM参数。我遇到了这个奇怪的错误。任何有关如何解决此错误的建议将不胜感激。

svm.default(x,y,scale = scale,...,na.action = na.action)中的错误:   p <0!

我在R中使用e1071和psoptim软件包来优化gamma,成本和epsilon参数。我不确定p <0!表示

data<- pca.train
train<-data.matrix(pca.train, rownames.force = NA)

rmse <- function(error)
{
  sqrt(mean(error^2))
}

f <- function(V1, V2,V3,x,y)
{
  V1 <-  log10(B1)
  V2 <-  log10(B2)
  V3 <-  log10(B3)


  svm.model <- svm(x=train, y=data$y1,scale=F, type= "eps-regression",kernel="radial",cost = V1,epsilon= V2,gamma= V3)
  error<- pca.train$y1- svm.model$fitted
  return (rmse(error))
}

B3<-  seq(1, 2,0.1)
B1<-  2^(2:9)
B2 <- seq(0.1,1, 0.1)

n <- 50
m.l <- 50
w <- 0.95
c1 <- 0.2
c2 <- 0.2
xmin <- c(-5.12, -5.12)
xmax <- c(5.12, 5.12)
vmax <- c(4, 4)


optimum <-psoptim(f, n=n, max.loop=m.l, w=w, c1=c1, c2=c2,xmin=xmin, xmax=xmax, vmax=vmax, seed=5, anim=FALSE)
OPTIMIM.VALUE<- f(optimum)

关于优化后如何获得伽玛值,成本和ε参数的优化值的任何建议也将很有帮助

0 个答案:

没有答案