lgb.Dataset.set.categorical.Rd 1.13 KB
Newer Older
Guolin Ke's avatar
Guolin Ke committed
1
2
3
4
5
6
7
8
9
10
11
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lgb.Dataset.R
\name{lgb.Dataset.set.categorical}
\alias{lgb.Dataset.set.categorical}
\title{Set categorical feature of \code{lgb.Dataset}}
\usage{
lgb.Dataset.set.categorical(dataset, categorical_feature)
}
\arguments{
\item{dataset}{object of class \code{lgb.Dataset}}

12
13
14
\item{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.
\code{c(1L, 10L)} to say "the first and tenth columns").}
Guolin Ke's avatar
Guolin Ke committed
15
16
}
\value{
17
the dataset you passed in
Guolin Ke's avatar
Guolin Ke committed
18
19
}
\description{
20
21
Set the categorical features of an \code{lgb.Dataset} object. Use this function
             to tell LightGBM which features should be treated as categorical.
Guolin Ke's avatar
Guolin Ke committed
22
23
}
\examples{
24
\donttest{
25
26
\dontshow{setLGBMthreads(2L)}
\dontshow{data.table::setDTthreads(1L)}
Guolin Ke's avatar
Guolin Ke committed
27
28
29
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
30
31
32
data_file <- tempfile(fileext = ".data")
lgb.Dataset.save(dtrain, data_file)
dtrain <- lgb.Dataset(data_file)
33
lgb.Dataset.set.categorical(dtrain, 1L:2L)
34
}
Guolin Ke's avatar
Guolin Ke committed
35
}