Skip to contents

Returns predictor variable (feature) importance of underlying LightGBM models stored in a fusion model file (.fsn) on disk.

Usage

importance(fsn)

Arguments

fsn

Character. Path to fusion model file (.fsn) generated by train.

Value

A named list containing detailed and summary importance results. The summary results are most useful, as they return the average importance of each predictor across potentially multiple underlying LightGBM models; i.e. zero ("z"), mean ("m"), or quantile ("q") models. See Examples for suggested plotting of results.

Details

Importance metrics are computed via lgb.importance. Three types of measures are returned; "gain" is typically the preferred measure.

Examples

# Build a fusion model using RECS microdata
# Note that "fusion_model.fsn" will be written to working directory
?recs
fusion.vars <- c("electricity", "natural_gas", "aircon")
predictor.vars <- names(recs)[2:12]
fsn.path <- train(data = recs, y = fusion.vars, x = predictor.vars)

# Extract predictor variable importance
ximp <- importance(fsn.path)

# Plot summary results
library(ggplot2)
ggplot(ximp$summary, aes(x = x, y = gain)) +
  geom_bar(stat = "identity") +
  facet_grid(~ y) +
  coord_flip()

# View detailed results
View(ximp$detailed)