Plot previously calculated feature contribution as a bar graph.

lgb.plot.interpretation(tree_interpretation_dt, top_n = 10L, cols = 1L,
  left_margin = 10L, cex = NULL)

Arguments

tree_interpretation_dt

a data.table returned by lgb.interprete.

top_n

maximal number of top features to include into the plot.

cols

the column numbers of layout, will be used only for multiclass classification feature contribution.

left_margin

(base R barplot) allows to adjust the left margin size to fit feature names.

cex

(base R barplot) passed as cex.names parameter to barplot.

Value

The lgb.plot.interpretation function creates a barplot.

Details

The graph represents each feature as a horizontal bar of length proportional to the defined contribution of a feature. Features are shown ranked in a decreasing contribution order.

Examples

library(lightgbm) Sigmoid <- function(x) {1.0 / (1.0 + exp(-x))} Logit <- function(x) {log(x / (1.0 - x))} data(agaricus.train, package = "lightgbm") train <- agaricus.train dtrain <- lgb.Dataset(train$data, label = train$label) setinfo(dtrain, "init_score", rep(Logit(mean(train$label)), length(train$label))) data(agaricus.test, package = "lightgbm") test <- agaricus.test 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 ) model <- lgb.train(params, dtrain, 10L) tree_interpretation <- lgb.interprete(model, test$data, 1L:5L) lgb.plot.interpretation(tree_interpretation[[1L]], top_n = 10L)