Reputation: 745
I am using the Caret package to tune a SVM model.
Is there a way to scale the Sigma
values similar to the Cost
values when plotting the results (as shown in the attached Fig.).
Here is my tuning values:
svmGrid <- expand.grid(sigma= 2^c(-25, -20, -15,-10, -5, 0), C= 2^c(0:5))
Code to produce the plot:
pdf("./Figures/svm/svmFit_all.pdf", width=7, height = 5)
trellis.par.set(caretTheme())
plot(svmFit.all, scales = list(x = list(log = 2)))
dev.off()
Thanks
Upvotes: 3
Views: 5603
Reputation: 14331
You would have to do it yourself via lattice:
library(caret)
set.seed(1345)
dat <- twoClassSim(2000)
svmGrid <- expand.grid(sigma= 2^c(-25, -20, -15,-10, -5, 0), C= 2^c(0:5))
set.seed(45)
mod <- train(Class ~ ., data = dat,
method = "svmRadial",
preProc = c("center", "scale"),
tuneGrid = svmGrid,
metric = "ROC",
trControl = trainControl(method = "cv",
classProbs = TRUE,
summaryFunction = twoClassSummary))
tmp <- mod$results
tmp$sigma2 <- paste0("2^", format(log2(tmp$sigma)))
xyplot(ROC ~ C, data = tmp,
groups = sigma2,
type = c("p", "l"),
auto.key = list(columns = 4, lines = TRUE),
scales = list(x = list(log = 2)),
xlab = "Cost",
ylab = "ROC (Cross-Validation)")
Max
Upvotes: 5