Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad input to predict n.trees causes crash #45

Closed
ngreifer opened this issue Jul 31, 2019 · 2 comments
Closed

Bad input to predict n.trees causes crash #45

ngreifer opened this issue Jul 31, 2019 · 2 comments

Comments

@ngreifer
Copy link

@ngreifer ngreifer commented Jul 31, 2019

When a numeric or integer of length 0 is given as an argument to n.trees in predict.gbm(), it causes a crash (not an error), forcing the reset of the R session. This should fail more gracefully so the error can at least be captured rather than causing a full crash.

Example (will cause a crash, so do it in its own R session):

library(gbm)
data("lalonde", package = "cobalt")

fit <- gbm(treat ~ age + educ + married, 
                 data = lalonde, n.trees = 100)
p <- predict(fit, n.trees = numeric()) #crash for non-NULL of length 0

@bgreenwell
Copy link
Contributor

@bgreenwell bgreenwell commented Jul 31, 2019

Thanks @ngreifer I’ll take a look soon and push a fix! You’re welcome to submit a PR as well!

@bgreenwell
Copy link
Contributor

@bgreenwell bgreenwell commented Jun 24, 2020

Sorry for the massive delay @ngreifer. Fixed in version 2.1.6 (will be on CRAN soon).

@bgreenwell bgreenwell closed this Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.