I am working on a PSO optimisation in R to optimize SVM parameters gamma, epsilon and C. I can optimise one variable but got this error when I use more than one variable.
Error in tune(svm, Train_Input_NonNorm, Train_Target_NonNorm, kernel = "radial", : argument "C" is missing, with no default
SVM_Nonnorm_Optim_f <- function(E,C,G)
{
set.seed(123)
SVM_NonNorm_Tune <-tune(svm,Train_Input_NonNorm,Train_Target_NonNorm, kernel="radial",ranges=
list(epsilon = E, cost = C, gamma=G))
SVM_NonNorm_tuned <- SVM_NonNorm_Tune$best.model
Predict_SVM_NonNorm_tuned <- predict(SVM_NonNorm_tuned,Train_Input_NonNorm)
RMSE_SVM_NonNorm_tuned <- sqrt(mean((Train_Target_NonNorm - Predict_SVM_NonNorm_tuned)^2))
return(RMSE_SVM_NonNorm_tuned)
}
n <- 50
m.l <- 50
w <- 0.95
c1 <- 2
c2 <- 2
xmin <- 0
xmax <- 1000
vmax <- c(4, 4)
SVM_NonNorm_PSO <- psoptim(SVM_Nonnorm_Optim_f, n=n, max.loop=m.l, w=w, c1=c1, c2=c2,
xmin=xmin, xmax=xmax, vmax=vmax, seed=5, anim=FALSE)`
I don't use
psoptim, but very likely you need to pass a vector of parameters, i.e. something likeWith only three parameters, there may be better methods, perhaps even a lowly grid search would do.