lishiwei2011 / gradientboostedmodels

Automatically exported from code.google.com/p/gradientboostedmodels
0 stars 0 forks source link

predict.gbm fails if n.trees not set #35

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.  run a gbm model with cv.folds=0
2.  call predict.gbm(model)

The error you will see is from this line in the source for predict.gbm:

    cat(paste("Using", n.trees, "trees...\n"))

and is caused by this line immediately above:

   best <- length(object$train.error)

The variable 'best' is never referenced again, I believe this is simple bug and 
n.trees should be set to the length of object$train.error if n.trees is not 
specified in the arguments.

This is bug arises in version 2.1 of gbm.

Original issue reported on code.google.com by kei...@datagami.info on 29 Jan 2015 at 8:30