lightgbm {lightgbm}R Documentation

Train a LightGBM model

Description

Simple interface for training an LightGBM model.

Usage

lightgbm(data, label = NULL, weight = NULL, params = list(),
  nrounds = 10, verbose = 1, eval_freq = 1L,
  early_stopping_rounds = NULL, save_name = "lightgbm.model",
  init_model = NULL, callbacks = list(), ...)

Arguments

data

a lgb.Dataset object, used for training

label

Vector of labels, used if data is not an lgb.Dataset

weight

vector of response values. If not NULL, will set to dataset

params

List of parameters

nrounds

number of training rounds

verbose

verbosity for output, if <= 0, also will disable the print of evaluation during training

eval_freq

evaluation output frequency, only effect when verbose > 0

early_stopping_rounds

int Activates early stopping. Requires at least one validation data and one metric If there's more than one, will check all of them except the training data Returns the model with (best_iter + early_stopping_rounds) If early stopping occurs, the model will have 'best_iter' field

save_name

File name to use when writing the trained model to disk. Should end in ".model".

init_model

path of model file of lgb.Booster object, will continue training from this model

callbacks

list of callback functions List of callback functions that are applied at each iteration.

...

Additional arguments passed to lgb.train. For example

  • validsa list of lgb.Dataset objects, used for validation

  • objobjective function, can be character or custom objective function. Examples include regression, regression_l1, huber, binary, lambdarank, multiclass, multiclass

  • evalevaluation function, can be (a list of) character or custom eval function

  • recordBoolean, TRUE will record iteration message to booster$record_evals

  • colnamesfeature names, if not null, will use this to overwrite the names in dataset

  • categorical_featurelist of str or int. type int represents index, type str represents feature names

  • reset_dataBoolean, setting it to TRUE (not the default value) will transform the booster model into a predictor model which frees up memory and the original datasets

  • boostingBoosting type. "gbdt" or "dart"

  • num_leavesnumber of leaves in one tree. defaults to 127

  • max_depthLimit the max depth for tree model. This is used to deal with overfit when #data is small. Tree still grow by leaf-wise.

  • num_threadsNumber of threads for LightGBM. For the best speed, set this to the number of real CPU cores, not the number of threads (most CPU using hyper-threading to generate 2 threads per CPU core).


[Package lightgbm version 2.2.2 Index]