lgb.importance {lightgbm}R Documentation

Compute feature importance in a model

Description

Creates a data.table of feature importances in a model.

Usage

lgb.importance(model, percentage = TRUE)

Arguments

model

object of class lgb.Booster.

percentage

whether to show importance in relative percentage.

Value

For a tree model, a data.table with the following columns:

Examples

library(lightgbm)
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 = 63, max_depth = -1,
              min_data_in_leaf = 1, min_sum_hessian_in_leaf = 1)
              model <- lgb.train(params, dtrain, 20)
model <- lgb.train(params, dtrain, 20)

tree_imp1 <- lgb.importance(model, percentage = TRUE)
tree_imp2 <- lgb.importance(model, percentage = FALSE)


[Package lightgbm version 2.2.2 Index]