Reputation: 43
I am trying to train a SVM model in R, using caret and doMC. Here is a reproducible example:
library(mlbench)
library(caret)
library(doMC)
registerDoMC(cores = 8)
training <- mlbench.cassini(5000)
Fitsvm<-train(classes ~ .,data=training,
preProcess=c('scale', 'center'),
method="svmRadial",
tuneGrid=expand.grid(sigma=0.5,C=c(0.01,0.05,0.1,0.5,1)))
But when I run this code, I get the following message:
Error in names(resamples) <- gsub("^\\.", "", names(resamples)) :
attempt to set an attribute on NULL
This error only appears when I try to run in parallel the SVM with caret, and only with the SVM model. When I run it with GBM or RF, the codes functions normally. Could you help me figure out what is wrong or how can I get it to run? Does caret support SVM parallelisation? Thank you.
I am running it on a Macbook pro, mid 2013 on 4 cores.
Upvotes: 3
Views: 839
Reputation: 23598
Your training object is a list, which you are passing as a data.frame.
If you change your training object into a data.frame it should work.
training <- data.frame(mlbench.cassini(5000))
Upvotes: 1