What does the expand.grid function in caret do?

r
caret
crossvalidation

#1

hello,

set.seed(123)
fitControl <- trainControl(method = 'cv', number = 10, summaryFunction=defaultSummary)
Grid <- expand.grid( n.trees = seq(50,1000,50), interaction.depth = c(30), shrinkage = c(0.1),n.minobsinnode = 10)

I came across the above code while learning about ensembles.
Can someone please help me understand the function expand.grid and it’s parameters.
I tried R help but:

Kindly help!!


#2

Hi @pagal_guy,

expand.grid function will help you create set of different tuning features as mentioned by you in above code. Now if you pass this grid while training your model, the model will return the the feature combination with best result. Generally this function is used to tune the parameters in modelling in an automated fashion, as this will automatically check all the possible tuning parameters and return the optimized parameters on which the model give the best accuracy.

Hope this helps.

Regards,
Aayush