[R] Using tune with gbm --grid search for best hyperparameters
Christopher Schwalm
schw0516 at umn.edu
Wed Mar 5 22:03:46 CET 2008
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
More information about the R-help
mailing list