4.5 Aside: Variable importance using lime (optional)

You may skip this part and move down to Section 4.6

In prescriptive analytics we are also interested in knowing the direction of the effect. For example, we expect that Balance is increasing the probability that a person buys insurance. However, caret does not tell us whether this is indeed true. In order to tackle this issue, we will use lime package.24 I won’t be able to go into the details here.

Note that we are using only 20 observations from the dt4_test data set to save time.

explainer_rf2 <- lime::lime(select(dt4_train, -starts_with("Call")),
                            modelRF2,
                            n_bins = 5) # number of bins for continuous variables

explanation_rf2 <- lime::explain(
  x = select(dt4_test[1:20, ], -CarInsurance, -starts_with("Call")),
  explainer = explainer_rf2,
  n_permutations = 5000, # default
  dist_fun = "gower",    # default
  kernel_width = 0.75,   # default
  n_features = 10,
  feature_select = "highest_weights",
  labels = "Yes"         # the label for the event "buy"
)

Plot the features

plot_explanations(explanation_rf2)

lime shows the results for each case separately. For instance, out of the 20 observations, 16 show increased probability of purchase if NoOfContacts is <= 2. Fore more details, please visit https://uc-r.github.io/lime.


  1. LIME stands for Local Interpretable Model-agnostic Explanations