lgb.model.dt.tree {lightgbm}R Documentation

Parse a LightGBM model json dump

Description

Parse a LightGBM model json dump into a data.table structure.

Usage

lgb.model.dt.tree(model, num_iteration = NULL, start_iteration = 1L)

Arguments

model

object of class lgb.Booster.

num_iteration

Number of iterations to include. NULL or <= 0 means use best iteration.

start_iteration

Index (1-based) of the first boosting round to include in the output. For example, passing start_iteration=5, num_iteration=3 for a regression model means "return information about the fifth, sixth, and seventh trees".

New in version 4.4.0

Value

A data.table with detailed information about model trees' nodes and leafs.

The columns of the data.table are:

Examples




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

params <- list(
  objective = "binary"
  , learning_rate = 0.01
  , num_leaves = 63L
  , max_depth = -1L
  , min_data_in_leaf = 1L
  , min_sum_hessian_in_leaf = 1.0
  , num_threads = 2L
)
model <- lgb.train(params, dtrain, 10L)

tree_dt <- lgb.model.dt.tree(model)


[Package lightgbm version 4.5.0 Index]