I am implementing a Support Vector Machine with Radial Basis Function Kernel ('svmRadial') with caret. As far as I understand the documentation and the source code, caret uses an analytical formula to get reasonable estimates of sigma and fix it to that value (According to the output: Tuning parameter 'sigma' was held constant at a value of 0.1028894). In addition, caret cross-validates over a set of cost parameters C (default = 3).
However, if I now want to set my own grid of cost parameters (tuneGrid), I have to additionally specify a value of sigma. Otherwise the following error appears:
Error: The tuning parameter grid should have columns sigma, C
How can I fix Sigma based on the analytical formula and still implement my own grid of cost parameters C?
Here is a MWE:
library(caret)
library(mlbench)
data(BostonHousing)
set.seed(1)
index <- sample(nrow(BostonHousing),nrow(BostonHousing)*0.75)
Boston.train <- BostonHousing[index,]
Boston.test <- BostonHousing[-index,]
# without tuneGrid
set.seed(1)
svmR <- train(medv ~ .,
data = Boston.train,
method = "svmRadial",
preProcess = c("center", "scale"),
trControl = trainControl(method = "cv", number = 5))
# with tuneGrid (gives the error message)
set.seed(1)
svmR <- train(medv ~ .,
data = Boston.train,
method = "svmRadial",
preProcess = c("center", "scale"),
tuneGrid = expand.grid(C = c(0.01, 0.1)),
trControl = trainControl(method = "cv", number = 5))