-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[R-package] lgb.cv() fails with categorical features #6412
Comments
Seems like I introduced this in #5184. I don't remember why I changed the condition from |
I experienced the same issue, but it seems like it does not throw the error (i.e. it seems to work) when you specify the 'categorical_feature' vector to be a vector of strings, the names of your features. i.e. cat_features = c("a","b","c"). I had no issues when I included this both in the train creating using lgb.Dataset() AND in lgb.cv(categorical_feature=cat_features). Hope this helps. |
Yes, that's a useful workaround that circumvents the bug in my example, too! |
Description
Executing a cross-validation with
lgb.cv()
fails when the data contains categorical features.Reproducible example
I'm using the example in the code demo categorical_features_rules:
In that example, a
lgb.Booster
is trained withmodel <- lgb.train( params = params , data = dtrain , nrounds = 100L , valids = list(train = dtrain, valid = dtest) )
after the training and test data had been previously created as
Works perfectly so far. Now, if I want to cross-validate using the training data set, by doing
I'm getting an error
Specifying the
categorical_feature
argument again inlgb.cv()
does not help.The error seems to be related to categorical features. When I'm, running a similar analysis without them,
lgb.cv()
works fine:Environment info
The text was updated successfully, but these errors were encountered: