[R] Using tune with gbm --grid search for best hyperparameters

From: Christopher Schwalm <schw0516_at_umn.edu>
Date: Wed, 05 Mar 2008 15:03:46 -0600


Hello LIST,

I'd like to use tune from e1071 to do a grid search for hyperparameter values in gbm. However, I can not get this to work. I note that there is no wrapper for gbm but that it is possible to use non-wrapped functions (like lm) without problem. Here's a snippet of code to illustrate.

> data(mtcars) obj <-
> gbm(mpg~disp+wt+carb,data=mtcars,distribution="gaussian",n.trees=1000,n.minobsinnode=5)
> summary(obj) #just to demonstrate that gbm worked

   var rel.inf

1 disp 55.185469
2   wt 40.198605
3 carb  4.615926

# now let's find the best value for n.minobsinnode using tune
> tune.obj <-
> tune(gbm,mpg~disp+wt+carb,data=mtcars,distribution="gaussian",n.trees=1000,n.minobsinnode=c(5,10,15))
Error in function (formula = formula(data), distribution = "bernoulli", :   unused argument(s) (subset = c(23, 9, 18, 26, 32, 28, 16, 5, 25, 24, 21, 8, 6, 7, 13, 1, 30, 17, 2, 29, 3, 27, 31, 12, 15, 11, 4, 22))

I've tried many variations on syntax --too many to count. But this error message will not go away. Does tune simply not work with gbm or is something else going on. Many thanks for any insight.

Christopher



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 05 Mar 2008 - 21:06:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 05 Mar 2008 - 21:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive