local_profile: Calculates Individual Variable Profiles aka Ceteris Paribus...

Description Usage Arguments Value Examples

Description

This explainer works for individual observations. For each observation it calculates Individual Variable Profiles for selected variables. For this reason it is also called 'Local Profile Plot'.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
individual_variable_profile(x, ...)

## S3 method for class 'explainer'
individual_variable_profile(x, new_observation,
  y = NULL, variables = NULL, variable_splits = NULL,
  grid_points = 101, ...)

## Default S3 method:
individual_variable_profile(x, data,
  predict_function = predict, new_observation, y = NULL,
  variables = NULL, variable_splits = NULL, grid_points = 101,
  label = class(x)[1], ...)

Arguments

x

a model to be explained, or an explainer created with function 'DALEX::explain()'.

...

other parameters

new_observation

a new observation with columns that corresponds to variables used in the model

y

true labels for 'new_observation'. If specified then will be added to ceteris paribus plots.

variables

names of variables for which profiles shall be calculated. Will be passed to 'calculate_variable_splits()'. If NULL then all variables from the validation data will be used.

variable_splits

named list of splits for variables, in most cases created with 'calculate_variable_splits()'. If NULL then it will be calculated based on validation data avaliable in the 'explainer'.

grid_points

number of points for profile. Will be passed to 'calculate_variable_splits()'.

data

validation dataset, will be extracted from ‘x' if it’s an explainer

predict_function

predict function, will be extracted from ‘x' if it’s an explainer

label

name of the model. By default it's extracted from the 'class' attribute of the model

Value

An object of the class 'ceteris_paribus_explainer'. It's a data frame with calculated average responses.

Examples

 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
27
28
29
30
31
32
33
34
library("DALEX2")
library("ceterisParibus2")
 ## Not run: 
library("randomForest")
set.seed(59)

apartments_rf <- randomForest(m2.price ~ construction.year + surface + floor +
                                no.rooms + district, data = apartments)

explainer_rf <- explain(apartments_rf,
                        data = apartments_test[,2:6], y = apartments_test$m2.price)

my_apartment <- apartments_test[1, ]

lp_rf <- individual_variable_profile(explainer_rf, my_apartment)
lp_rf

plot(lp_rf)

# --------
# multiclass

HR_rf <- randomForest(status ~ . , data = HR)
explainer_rf <- explain(HR_rf, data = HRTest, y = HRTest)

my_HR <- HRTest[1, ]

lp_rf <- individual_variable_profile(explainer_rf,  my_HR)
lp_rf

plot(lp_rf, color = "_label_")


## End(Not run)

pbiecek/ceterisParibus2 documentation built on Sept. 16, 2019, 6:26 p.m.