topepo / APM_Exercises

Exercises for the book Applied Predictive Modeling by Kuhn and Johnson (2013)
194 stars 159 forks source link

setting n.minobsinnode in Ch08 #10

Open bowerth opened 7 years ago

bowerth commented 7 years ago

https://topepo.github.io/caret/model-training-and-tuning.html#basic-parameter-tuning

For a gradient boosting machine (GBM) model, there are three main tuning parameters:

<<ch08_permeabilityGBMTune, echo = TRUE, eval = TRUE, cache = TRUE>>=
set.seed(614)
gbmGrid <- expand.grid(interaction.depth=seq(1,6,by=1),
                       n.trees=c(25,50,100,200),
                       shrinkage=c(0.01,0.05,0.1))
gbmPermTune <- train(x = trainFingerprints, y = log10(trainPermeability),
                     method = "gbm",
                     verbose = FALSE,
                     tuneGrid = gbmGrid,
                     trControl = ctrl)
@
Error: The tuning parameter grid should have columns n.trees, interaction.depth, shrinkage, n.minobsinnode
topepo commented 7 years ago

Sinew the book was written, an extra tuning parameter was added to the model code. You can use

gbmGrid <- expand.grid(interaction.depth=seq(1,6,by=1),
                       n.trees=c(25,50,100,200),
                       shrinkage=c(0.01,0.05,0.1),
                       n.minobsinnode = 10)