lgbm.fi.plot: LightGBM Feature Importance Plotting

Description Usage Arguments Value Examples

Description

This function allows to plot the feature importance on a LightGBM model.

Usage

1
2
3
lgbm.fi.plot(model, n_best = 50, no_log = TRUE, low = "white",
  high = "red", rescaler = "log", is.cv = FALSE, multipresence = TRUE,
  plot = TRUE)

Arguments

model

Type: list, data.table, or data.frame. The trained model (with feature importance), or the feature importance table. If a list is provided, the trained model must have had importance set to TRUE during training. Otherwise, compute manually the feature importance via lgbm.fi, and feed the output table to this function argument.

n_best

Type: integer. The maximum amount of features to plot. Defaults to 50.

no_log

Type: boolean. Whether to NOT apply a log10 scale to the plot. Defaults to TRUE.

low

Type: character. The color when the relative gain is 0. Defaults to "white".

high

Type: character. The color when the relative gain is 1. Defaults to "red".

rescaler

Type: character. The transformation of the color scale. Defaults to "log". Choose between "asn", "atanh", "boxcox", "exp", "identity" (linear scale), "log", "log10", "log1p", "log2", "logit", "probability", "probit", "reciprocal", "reverse", "sqrt", or any other ggplot2 transformation object.

is.cv

Type: boolean. Whether the input is issued from a cross-validation or not. Defaults to FALSE.

multipresence

Type: boolean. Whether in a cross-validation, only the features which always appear are kept. Otherwise, they are thrown away for safety. Defaults to TRUE.

plot

Type: boolean. Whether to print a plot. Defaults to TRUE.

Value

A ggplot2 object which contains the plot.

Examples

1
2
3
4
5
6
7
8
## Not run: 
# Feature importance on a single model without any tree limit, 20 best features are plotted.
feature_imp <- lgbm.fi(model = trained, feature_names = colnames(data), ntreelimit = 0)
feature_plot <- lgbm.fi.plot(feature_imp, n_best = 20, rescaler = "log",
is.cv = FALSE, multipresence = FALSE, plot = FALSE)
print(featuer_plot)

## End(Not run)

Laurae2/Laurae documentation built on May 8, 2019, 7:59 p.m.