R: Construct 'lgb.Dataset' object

lgb.Dataset {lightgbm} | R Documentation

## Construct `lgb.Dataset` object

### Description

Construct `lgb.Dataset` object from dense matrix, sparse matrix or local file (that was created previously by saving an `lgb.Dataset`).

### Usage

    lgb.Dataset(
      data,
      params = list(),
      reference = NULL,
      colnames = NULL,
      categorical_feature = NULL,
      free_raw_data = TRUE,
      info = list(),
      ...
    )

### Arguments

`data` | a `matrix` object, a `dgCMatrix` object or a character representing a filename
`params` | a list of parameters
`reference` | reference dataset
`colnames` | names of columns
`categorical_feature` | categorical features
`free_raw_data` | TRUE for need to free raw data after construct
`info` | a list of information of the `lgb.Dataset` object
`...` | other information to pass to `info` or parameters pass to `params`

### Value

constructed dataset

### Examples

    library(lightgbm)
    data(agaricus.train, package = "lightgbm")
    train <- agaricus.train
    dtrain <- lgb.Dataset(train$data, label = train$label)
    lgb.Dataset.save(dtrain, "lgb.Dataset.data")
    dtrain <- lgb.Dataset("lgb.Dataset.data")
    lgb.Dataset.construct(dtrain)

[Package lightgbm version 2.3.1 Index]