I am trying to run this code for SVM in caret with a stratified cross-validation but I get this error:"Std. deviations could not be computed for: diff1, diff2, diff3, diff4, diff5, diff6,...model fit failed for Resample01: sigma=0.000, C=0.010 Error in if (any(co)) { : missing value where TRUE/FALSE needed"
"diff1, diff2, diff3, diff4, diff5, diff6,..." are the quantitative variables used for the prediction of a factor variable with 2 levels
set.seed(1)
folds<-createFolds(file_test$y,k=10,list=FALSE) # statified folds for cross-validation
ctrl<-trainControl(method="repeatedcv",index=folds,classProbs = TRUE,summaryFunction = twoClassSummary)
grid_radial <- expand.grid(
sigma = c(0,0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75,0.9),
C = c(0.01,0.025,0.05,0.075,0.1,0.25, 0.5, 0.75, 1))
SVMrad<-train(y ~., data=file_test,
method="svmRadial", # SVM algorithm
tuneGrid = grid_radial,
trControl=ctrl,
preProc=c("center","scale"),
metric="ROC")
I checked the 'file_test' but there are no missing values.
I hope you can help me fix this.
I finally found what was wrong: I had to use the option "list=TRUE" in the createFolds function:
folds<-createFolds(file_test$y,k=10,list=TRUE)