1
$\begingroup$

I am using the package caret and GBM method for my predictions.

fitControl <- trainControl(## 10-fold CV
        method = "repeatedcv",
        number = 10,
        ## repeated ten times
        repeats = 10)

gbmGrid <-  expand.grid(interaction.depth = c(1, 5, 9),
                        n.trees = (1:30)*50,
                        shrinkage = 0.1)

gbmFit <- train(target ~ ., data = traindf,
                method = "gbm",
                trControl = fitControl,
                verbose = FALSE,
                ## Now specify the exact models 
                ## to evaludate:
                tuneGrid = gbmGrid,
                metric = "ROC")

There is one concept that I misunderstand. User guides of caret say that "By default, the train function chooses the model with the largest performance value (or smallest, for mean squared error in regression models)." So, when I run ggplot(gbmFit) I get this graphic:

enter image description here

When I type gbmFit in the console, I see that "The final values used for the model were n.trees = 300, interaction.depth = 9 and shrinkage = 0.1" How can I manually change these settings in order to make my predictions with different number of boosting iterations and trees?:

predictions_gbm <- predict(gbmFit, newdata = testdf, type = "raw")
$\endgroup$
1
$\begingroup$

See ?update.train. For example:

new_mod <- update(gbmFit, list(n.trees = 100, 
                               interaction.depth = 1,
                               shrinkage = 0.1))
$\endgroup$
  • 1
    $\begingroup$ Can you add some text relating this to the OP's question / explaining how this resolves the issue? I suspect you're right, but it might be nice to have a little more. $\endgroup$ – gung Mar 27 '15 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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