plot_metrics: Plot of LIME Comparison Metrics

Description Usage Arguments Details References Examples

View source: R/plot_metrics.R

Description

Plots the specified comparison metrics versus LIME tuning parameters.

Usage

1
2
3
4
5
6
7
8
9
plot_metrics(
  explanations,
  metrics = "all",
  add_lines = FALSE,
  rank_legend = "continuous",
  point_size = 2,
  line_size = 0.5,
  line_alpha = 1
)

Arguments

explanations

Explain data frame from the list returned by apply_lime.

metrics

Vector specifying metrics to compute. Default is 'all'. See details for metrics available.

add_lines

Draw lines between tuning parameters with the same gower power.

rank_legend

Specifies whether the legend for rank is treated as 'continuous' or 'discrete'.

point_size

Specifies the size of the points.

line_size

Specifies the size of the lines (if add_lines is TRUE).

line_alpha

Specifies the alpha of the lines (if add_lines is TRUE).

Details

The metrics available are listed below.

References

Ribeiro, M. T., S. Singh, and C. Guestrin, 2016: "Why should I trust you?": Explaining the predictions of any classifier. Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, San Francisco, CA, USA, August 13-17, 2016, 1135–1144.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Prepare training and testing data
x_train = sine_data_train[c("x1", "x2", "x3")]
y_train = factor(sine_data_train$y)
x_test = sine_data_test[1:5, c("x1", "x2", "x3")]

# Fit a random forest model
rf <- randomForest::randomForest(x = x_train, y = y_train) 

# Run apply_lime
res <- apply_lime(train = x_train, 
                  test = x_test, 
                  model = rf,
                  label = "1",
                  n_features = 2,
                  sim_method = 'quantile_bins',
                  nbins = 2:3, 
                  gower_pow = c(1, 5))

# Plot metrics to compare LIME implementations
plot_metrics(res$explain)

# Return a plot with only the MSEE values
plot_metrics(res$explain, metrics = "msee")

goodekat/limeaid documentation built on March 26, 2021, 10:45 p.m.