lightgbm (version 4.3.0)

slice: Slice a dataset

Description

Get a new lgb.Dataset containing the specified rows of original lgb.Dataset object

Usage

slice(dataset, idxset)

# S3 method for lgb.Dataset slice(dataset, idxset)

Value

constructed sub dataset

Arguments

dataset

Object of class lgb.Dataset

idxset

an integer vector of indices of rows needed

Examples

Run this code
# \donttest{
setLGBMthreads(2L)
data.table::setDTthreads(1L)
data(agaricus.train, package = "lightgbm")
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)

dsub <- lightgbm::slice(dtrain, seq_len(42L))
lgb.Dataset.construct(dsub)
labels <- lightgbm::get_field(dsub, "label")
# }

Run the code above in your browser using DataLab