I am in the process of creating a Radial SVM Classification model and I would to perform 5-fold CV on it and tune it. I have seen how others do it here and followed these instructions. However, my code does not want to implement my tuning grid. Also, I do not understand why I cannot get Accuracy or an F1 value when I train the model explicitly.
With 5-fold CV
library(caret)
set.seed(500)
ctrl <- trainControl(method = "repeatedcv",
number = 5,
repeats = 3,
classProb=T,
summaryFunction = twoClassSummary
)
sigma<-c(2^-15,2^-13,2^-11,2^-9,2^-7,2^-5,2^-3,2^-1,2^1,2^2,2^3)
C<-c(2^-5,2^-3,2^-1,2^1,2^2,2^3,2^5,2^7,2^9,2^11,2^13)
tuninggrid<-data.frame(expand.grid(sigma,C))
mod <- train(x = iris[-5], y=iris$Species,
method = "svmRadial",
trControl = ctrl,
metric=c('ROC'),
tunegrid=tuninggrid
The results are simply sigma was held constant. Why does it not use my tuning grid?
Secondly, when I adjust the metric from 'ROC'
to 'Accuracy'
, it says Accuracy is not available. This I understand is because of my summaryFunction in trainControl.
If I remove it, then I can get Accuracy, but not ROC. Ultimately, I would like both and an F1 value, but I cannot find documentation on this. How would I write something to give me both at the same time?
Lastly, the output from train()
. To get the weights, it is just using mod$finalModel@coef correct?