I am using the caret package in R with the 'C5.0' train method. I am trying to implement kfold cross validation but it is taking too much time to build the model. How can I adjust my parameters so that it takes less time? My train data has 30,000 samples.

#My code
train_control <- trainControl(method="repeatedcv", number=10, repeats=3)

c50Grid <- expand.grid(.trials = c(1:9, (1:10)*10),
                       .model = c("tree", "rules"),
                       .winnow = c(TRUE, FALSE))

c5Fitvac <- train(y ~ .,
                  data = trainV,
                  method = "C5.0",
                  tuneGrid = c50Grid,
                  trControl = train_control,
                  metric = "Accuracy", 
                  preProc = c("center", "scale")) 
  • $\begingroup$ Welcome to CrossValidated. Notice I edited your post to highlight code formatting. When you say it's "taking too much time", how much is too much? Is it taking hours/days? Also, how many features you have? How many are categorical and how many categories do these have? $\endgroup$
    – Firebug
    Sep 18, 2016 at 22:35
  • 1
    $\begingroup$ Notice your grid has 76 parameter combinations, you are doing 10-fold CV with 3 repeats. That's a total of 2280 evaluations. $\endgroup$
    – Firebug
    Sep 18, 2016 at 22:39
  • $\begingroup$ so my last attempt took a few hours . I am trying another run and it has been running for an hour. I have 16 features, 8 are categorical with each between 2-4 categories. How do you get 76 evaluations? Sorry I know this is a silly quesiton $\endgroup$ Sep 18, 2016 at 22:54
  • $\begingroup$ sorry, I meant 76 combinations $\endgroup$ Sep 18, 2016 at 23:12
  • $\begingroup$ 19 entries in trials, 2 in model, 2 in winnow. $\endgroup$
    – Firebug
    Sep 19, 2016 at 2:55

1 Answer 1


To complement @Firebug comment, note that you also use repeated cross-validation (3 times) which slows down the whole process.

(See : In caret what is the real difference between cv and repeatedcv? for more information about repeated CV)

I would go for a coarser grid (you do not need 19 different values of trials), and would use a simple cross validation.

  • $\begingroup$ Thank you all, this really helped. I used much fewer combinations with simple cross validation and got decent results. I am now stuck with neuralnet and creating another post. Thanks much! $\endgroup$ Sep 21, 2016 at 0:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.