gbm-developers / gbm

Gradient boosted models (the old gbm package)
Other
51 stars 27 forks source link

summary and plot fails with errors on object of class gbm #36

Closed wolski closed 5 years ago

wolski commented 5 years ago

These are the errors produced.

> summary(diachp.boost)
Error in plot.window(xlim, ylim, log = log, ...) : 
  need finite 'xlim' values
In addition: Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
> plot(diachp.boost,1,best)
Error in plot.gbm(diachp.boost, 1, best) : object 'best' not found

below is the code to reproduce it. I do attach the diachp.Rds file in zip archive (direct upload of Rds files not posibble).

library(gbm)
diachp<- readRDS("diachp.Rds")
diachp.boost<-gbm(cheap~.,
                  data=diachp,
                  shrinkage=0.001,
                  distribution="bernoulli",
                  n.trees=300,
                  verbose=F)

#diachp.boost <-gbm(cheap~., data=diachp)
summary(diachp.boost)
plot(diachp.boost,1,best)

diachp.zip

bgreenwell commented 5 years ago

@wolski This is odd indeed. The fitted models is essentially empty! I'll look into it over the next couple of days!

bgreenwell commented 5 years ago

I see the issue @wolski. Your response is coded as 0/1, but stored with class "factor". Using distribution = "bernoulli" requires the response to be an integer coded as 0/1. gbm has never done a good job at checking for this via the formula method, so perhaps we can improve this before the next release (which will hopefully be soon). For now, the following should work:

diachp.boost <- gbm(
  as.integer(cheap) - 1 ~ .,
  data = diachp,
  shrinkage = 0.001,
  distribution = "bernoulli",
  n.trees = 300,
  verbose = F
)
bgreenwell commented 5 years ago

Closing this issue and opening a new one here https://github.com/gbm-developers/gbm/issues/37.