hierarchical_importance: Calculates importance of hierarchically grouped aspects

Description Usage Arguments Value Examples

View source: R/hierarchical_importance.R

Description

This function creates a tree that shows order of feature grouping and calculates importance of every newly created aspect.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
hierarchical_importance(
  x,
  data,
  y = NULL,
  predict_function = predict,
  type = "predict",
  new_observation = NULL,
  N = 1000,
  loss_function = DALEX::loss_root_mean_square,
  B = 10,
  fi_type = c("raw", "ratio", "difference"),
  clust_method = "complete",
  cor_method = "spearman",
  ...
)

## S3 method for class 'hierarchical_importance'
plot(
  x,
  absolute_value = FALSE,
  show_labels = TRUE,
  add_last_group = TRUE,
  axis_lab_size = 10,
  text_size = 3,
  ...
)

Arguments

x

a model to be explained.

data

dataset NOTE: Target variable shouldn't be present in the data

y

true labels for data

predict_function

predict function

type

if predict then aspect_importance is used, if model than feature_importance is calculated

new_observation

selected observation with columns that corresponds to variables used in the model, should be without target variable

N

number of rows to be sampled from data NOTE: Small N may cause unstable results.

loss_function

a function that will be used to assess variable importance, if type = model

B

integer, number of permutation rounds to perform on each variable in feature importance calculation, if type = model

fi_type

character, type of transformation that should be applied for dropout loss, if type = model. "raw" results raw drop losses, "ratio" returns drop_loss/drop_loss_full_model.

clust_method

the agglomeration method to be used, see hclust methods

cor_method

the correlation method to be used see cor methods

...

other parameters

absolute_value

if TRUE, aspects importance values will be drawn as absolute values

show_labels

if TRUE, plot will have annotated axis Y

add_last_group

if TRUE, plot will draw connecting line between last two groups

axis_lab_size

size of labels on axis Y, if applicable

text_size

size of labels annotating values of aspects importance

Value

ggplot

Examples

1
2
3
4
5
6
7
8
library(DALEX)
apartments_num <- apartments[,unlist(lapply(apartments, is.numeric))]
apartments_num_lm_model <- lm(m2.price ~ ., data = apartments_num)
hi <- hierarchical_importance(x = apartments_num_lm_model,
 data = apartments_num[,-1],
 y = apartments_num[,1],
 type = "model")
plot(hi, add_last_group = TRUE, absolute_value = TRUE)

triplot documentation built on July 13, 2020, 5:08 p.m.