I am building a model which have factor variables but numeric entries. I converted them to numeric. When I tried building the model with SVM radial kernel, I received some weird messages that I dont understand. Below is what I did.
Subset of data
class ac_000 ad_000 ag_007
neg 2130706438 280 25896
neg 228 100 292936
pos 42328 856 51190
neg 24 24 0
neg 370 346 0
pos 1534 1388 794698
factorconvert <- function(f){as.numeric(levels(f))[f]}
DF[, 2:4] <- lapply(DF[, 2:4], factorconvert)
SVM
ctrl<-trainControl(method="repeatedcv"),
repeats=5,
summaryFunction=twoClassSummary,
classProbs=TRUE)
Train and Tune the SVM
svm.tune <- train(x=trainX, y= trainData$Class,method = "svmRadial",
tuneLength = 9, preProc =c("center","scale"),metric="ROC",trControl=ctrl)
Error in if (any(co)) { : missing value where TRUE/FALSE needed In
addition: Warning message: In FUN(newX[, i], ...) : NAs introduced by
coercion.
any(is.any(DF)).
I also removed all NAs in the data with na.omit(). I rechecked the data. No missing values were present. I need help.