lgb.Dataset.set.categorical: Set categorical feature of 'lgb.Dataset'

View source: R/lgb.Dataset.R

lgb.Dataset.set.categoricalR Documentation

Set categorical feature of lgb.Dataset

Description

Set the categorical features of an lgb.Dataset object. Use this function to tell LightGBM which features should be treated as categorical.

Usage

lgb.Dataset.set.categorical(dataset, categorical_feature)

Arguments

dataset

object of class lgb.Dataset

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. c(1L, 10L) to say "the first and tenth columns").

Value

the dataset you passed in

Examples




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)
dtrain <- lgb.Dataset(data_file)
lgb.Dataset.set.categorical(dtrain, 1L:2L)


lightgbm documentation built on Sept. 11, 2024, 8:44 p.m.