[R] caret train and trainControl

Brian Feeny bfeeny at mac.com
Fri Nov 23 23:52:18 CET 2012


I am used to packages like e1071 where you have a tune step and then pass your tunings to train.

It seems with caret, tuning and training are both handled by train.

I am using train and trainControl to find my hyper parameters like so:

MyTrainControl=trainControl(
  method = "cv",
  number=5,
  returnResamp = "all",
   classProbs = TRUE
)

rbfSVM <- train(label~., data = trainset,                 
               method="svmRadial",
               tuneGrid = expand.grid(.sigma=c(0.0118),.C=c(8,16,32,64,128)),  
               trControl=MyTrainControl,
               fit = FALSE
)

Once this returns my ideal parameters, in this case Cost of 64, do I simply just re-run the whole process again, passing a grid only containing the specific parameters? like so?


rbfSVM <- train(label~., data = trainset,                 
               method="svmRadial",
               tuneGrid = expand.grid(.sigma=0.0118,.C=64),  
               trControl=MyTrainControl,
               fit = FALSE
)

This is what I have been doing but I am new to caret and want to make sure I am doing this correctly.

Brian



More information about the R-help mailing list