I was running an svm call from the package e1071 on R using the code below.
model = svm(AgeBucket~., data=mydata, control=svm.control(cp=0.01))
However, I get the below error.
Error in `contrasts<-`(`*tmp*`, value = contr.funs[1 + isOF[nn]]) :
contrasts can be applied only to factors with 2 or more levels
I searched around a bit and have tried the following but still the error persists.
- Removed all NAs
- Converted all columns to factors
- Called gc() the garbage collector after every fold of my k-fold cross validation