2

I was trying to do classification problem with gum function in R

library(gbm)
set.seed(1)
boost.goodwine = gbm(goodwine~.-quality,data = traindata,shrinkage = 0.01, cv.folds = 5,distribution = 'bernoulli',n.trees = 3000,interaction.depth = 3)

Here, goodwine is a collection of two classes(0 and 1)

head(goodwine)
0 0 1 1 0 0

My question is that if I change goodwine into factors, then gbm would give error saying that

goodwine = as.factor(goodwine)
Error in res[flag, ] <- predictions : replacement has length zero

But if I keep goodwine as numeric values, then it would give me satisfying result, but I am afraid that if I keep 0,1 as numeric values, gbm would recognise it as regression problem.

Can anyone give me explanation, or I guess the 'distribution = 'bernoulli' will automatically define this as a classification problem.

  • It seems to me that's `cv.folds=5` fault, when you remove that part it should work. Don't know what's the problem though. – RLave Dec 04 '18 at 15:03

0 Answers0