lishiwei2011 / gradientboostedmodels

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

gbm.fit with multinomial outcomes #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
gbm() works great with multinomial outcomes, but gbm.fit() does not. Since 
gbm() requires a formula it is less efficient and using gbm.fit() would be 
preferred for me (and works for other distributions).

> test <- gbm.fit(iris[, 1:4], iris$Species, distribution = "multinomial")
Iter   TrainDeviance   ValidDeviance   StepSize   Improve
     1           nan             nan     0.0010       nan
     2           nan             nan     0.0010       nan
     3           nan             nan     0.0010       nan
     4           nan             nan     0.0010       nan
     5           nan             nan     0.0010       nan
     6           nan             nan     0.0010       nan
     7           nan             nan     0.0010       nan
     8           nan             nan     0.0010       nan
     9           nan             nan     0.0010       nan
    10           nan             nan     0.0010       nan
    20           nan             nan     0.0010       nan
    40           nan             nan     0.0010       nan
    60           nan             nan     0.0010       nan
    80           nan             nan     0.0010       nan
   100           nan             nan     0.0010       nan

> test
NULL
A gradient boosted model with multinomial loss function.
100 iterations were performed.
There were 4 predictors of which 0 had non-zero influence.
> predict(test, head(iris[, 1:4]), n.trees = 50)
, , 50

     setosa versicolor virginica
[1,]     NA         NA        NA
[2,]     NA         NA        NA
[3,]     NA         NA        NA
[4,]     NA         NA        NA
[5,]     NA         NA        NA
[6,]     NA         NA        NA

> sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] parallel  splines   stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
[1] gbm_2.0-9.3      lattice_0.20-10  survival_2.36-14

loaded via a namespace (and not attached):
[1] grid_2.15.2

Original issue reported on code.google.com by MxK...@gmail.com on 6 Feb 2013 at 2:41

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
As discussed, fixed. Future builds will include the fix.

Original comment by harry.southworth on 11 Apr 2013 at 2:54

GoogleCodeExporter commented 8 years ago
However, It still can't work for me.

> model <- gbm(trainlabel~.,data=train,distribution = "bernoulli")
> predict1 <- predict.gbm(model,train,100,type="response")
> predict1
  [1] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
 [26] NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

Original comment by guoshich...@gmail.com on 20 Feb 2014 at 6:36