plot_features: Plot the features in an explanation

Description Usage Arguments Value See Also Examples

View source: R/plot.R

Description

This functions creates a compact visual representation of the explanations for each case and label combination in an explanation. Each extracted feature is shown with its weight, thus giving the importance of the feature in the label prediction.

Usage

1
plot_features(explanation, ncol = 2, cases = NULL)

Arguments

explanation

A data.frame as returned by explain().

ncol

The number of columns in the facetted plot

cases

An optional vector with case names to plot. explanation will be filtered to only include these cases prior to plotting

Value

A ggplot object

See Also

Other explanation plots: plot_explanations(), plot_text_explanations()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Create some explanations
library(MASS)
iris_test <- iris[1, 1:4]
iris_train <- iris[-1, 1:4]
iris_lab <- iris[[5]][-1]
model <- lda(iris_train, iris_lab)
explanation <- lime(iris_train, model)
explanations <- explain(iris_test, explanation, n_labels = 1, n_features = 2)

# Get an overview with the standard plot
plot_features(explanations)

lime documentation built on Feb. 24, 2021, 5:08 p.m.