How to set the parameters of gbm boost in R

r
gbm
boosting

#1

hello,

While trying to implement boosting in R using caret I used the following code:

library(ISLR);
data(Wage);
library(ggplot2);
library(caret);
Wage <- subset(Wage,select=-c(logwage))
inTrain <- createDataPartition(y=Wage$wage,p=0.7, list=FALSE)
training <- Wage[inTrain,]; testing <- Wage[-inTrain,]
#Fit the model:
modFit <- train(wage ~ ., method="gbm",data=training,verbose=FALSE)
print(modFit)

This gives an output:

Here some values like n.trees etc. are selected by default.
How do I set the values,for example I want to set n.trees = 500 etc.


#2

Hi Pagal

time to read about cater I think, you can overwrite the default parameters in caret by giving the original parameters name at the end of the train() call. (not in Grid and not in control structure)

Example for RF for grid and control and other parameters such as proximity and trees (caret in grid allows mtry only, we increase ntree to 1500 when default is 500)

rfmodel <-train(formula(optformula),
data= trainmodeldataset,
trControl = samplingmethod,
tuneGrid = rfvariables,
method= “rf”,
verbose=FALSE,
metric=“RMSE”,
proximity= TRUE,
importance=TRUE,
ntrees = 1500)

Hope this help. Do forget to go through the very good caret documentation!!
Alain