title: Gradient Boosting using gbm in R with distribution = "bernoulli"
body: <p>I am using <code>gbm</code> package in <code>R</code> and applying the 'bernoulli' option for distribution to build a classifier and i get unusual results of 'nan' and i'm unable to predict any classification results. But i do not encounter the same errors when i use 'adaboost'. Below is the sample code, i replicated the same errors with the iris dataset.</p>
  
  <pre><code>## using the iris data for gbm
  library(caret)
  library(gbm)
  data(iris)
  Data  &lt;- iris[1:100,-5]
  Label &lt;- as.factor(c(rep(0,50), rep(1,50)))
  
  # Split the data into training and testing
  inTraining &lt;- createDataPartition(Label, p=0.7, list=FALSE)
  training &lt;- Data[inTraining, ]
  trainLab &lt;- droplevels(Label[inTraining])
  testing &lt;- Data[-inTraining, ]
  testLab &lt;- droplevels(Label[-inTraining])
  
  # Model
  model_gbm &lt;- gbm.fit(x=training, y= trainLab,
                       distribution = "bernoulli",
                       n.trees = 20, interaction.depth = 1,
                       n.minobsinnode = 10, shrinkage = 0.001,
                       bag.fraction = 0.5, keep.data = TRUE, verbose = TRUE)
  
  ## output on the console
  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
  </code></pre>
  
  <p>Please let me know if there is a work around to get this working. The reason i am using this is to experiment with Additive Logistic Regression, please suggest if there are any other alternatives in R to go about this.</p>
  
  <p>Thanks. </p>