1

Sorry for the dumb question. I'm running the following code:

gbm_mdl <- do.call(train,
             c(list(x=L0FeatureSet1$train$predictors,y=L0FeatureSet1$train$y),
             CARET.TRAIN.PARMS,
             MODEL.SPECIFIC.PARMS,
             CARET.TRAIN.OTHER.PARMS))

Predictor has a bunch of independent variables and y is the target. I get the following error:

Error in gbm.fit(x = list(Neighborhood = c(17L, 17L, 17L, 17L, 17L, 17L,  :         
variable 1: Neighborhood is not of type numeric, ordered, or factor.

However, if I test for "Neighborhood" in my predictors, it's a factor:

is.factor(L0FeatureSet1$train $predictors$Neighborhood[1])
[1] TRUE
 class(L0FeatureSet1$train $predictors$Neighborhood)
[1] "factor"

I'm also running a xgboost and ranger model with the same list of parameters and it works for both of those.

Does anyone know how I should proceed to fix this? Thanks

Sunny
  • 21
  • 2
  • It would be easier to help you if you provided a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input data so we can see what are in all the variables. The error seems to imply that `x` is being passed as a list rather than a numeric vector. – MrFlick Sep 25 '16 at 01:44
  • You've got the transformation to list right in your code. Take it out. – Hack-R Sep 25 '16 at 02:10
  • MrFlick, thank you for the reply. I've been trying to make a small sample. However, anything below 100, gbm complains the sample is too small. Also, my code has many helper functions. Is it ok if I post everything? – Sunny Sep 25 '16 at 02:24
  • Hack-R: the list is necessary for the do.call function. It will still take x as x and y as y – Sunny Sep 25 '16 at 02:24
  • I fixed it by taking the predictors out as a data frame (which is already was) and passing it in again. Still don't understand why that worked though – Sunny Sep 25 '16 at 02:49

0 Answers0