Set the categorical features of an lgb.Dataset
object. Use this function
to tell LightGBM which features should be treated as categorical.
lgb.Dataset.set.categorical(dataset, categorical_feature)
dataset | object of class |
---|---|
categorical_feature | categorical features. This can either be a character vector of feature
names or an integer vector with the indices of the features (e.g.
|
the dataset you passed in
# \donttest{ data(agaricus.train, package = "lightgbm") train <- agaricus.train dtrain <- lgb.Dataset(train$data, label = train$label) data_file <- tempfile(fileext = ".data") lgb.Dataset.save(dtrain, data_file) #> [LightGBM] [Info] Saving data to binary file /tmp/RtmpFi7Csu/filef0c5bf89fc8.data dtrain <- lgb.Dataset(data_file) lgb.Dataset.set.categorical(dtrain, 1L:2L) # }