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")

closed as off-topic by kjetil b halvorsen, Michael R. Chernick, mkt - Reinstate Monica, Robert Long, Peter Flom - Reinstate Monica Oct 8 at 9:58

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – kjetil b halvorsen, Michael R. Chernick, mkt - Reinstate Monica, Robert Long, Peter Flom - Reinstate Monica
If this question can be reworded to fit the rules in the help center, please edit the question.


See ?update.train. For example:

new_mod <- update(gbmFit, list(n.trees = 100, 
                               interaction.depth = 1,
                               shrinkage = 0.1))
  • 2
    $\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 - Reinstate Monica Mar 27 '15 at 18:52

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