Description Usage Arguments Value Examples
View source: R/local_conditional_expectations.R
This explainer works for individual observations. For each observation it calculates Local Conditional Expectation (LCE) profiles for selected variables.
1 2 3 4 5 6 7 8 9 10 11 12 | individual_conditional_expectations(x, ...)
## S3 method for class 'explainer'
individual_conditional_expectations(x, new_observation,
y = NULL, variables = NULL, variable_splits = NULL,
grid_points = 101, ...)
## Default S3 method:
individual_conditional_expectations(x, data,
predict_function = predict, new_observation, y = NULL,
variable_splits = NULL, variables = NULL, grid_points = 101,
label = class(x)[1], ...)
|
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 |
An object of the class 'individual_variable_profile_explainer'. A data frame with calculated LCE profiles.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | library("DALEX2")
## Not run:
library("randomForest")
set.seed(59)
apartments_rf_model <- randomForest(m2.price ~ construction.year + surface + floor +
no.rooms + district, data = apartments)
explainer_rf <- explain(apartments_rf_model,
data = apartments[,2:6], y = apartments$m2.price)
new_apartment <- apartments[1, ]
lce_rf <- individual_conditional_expectations(explainer_rf, new_apartment)
lce_rf
lce_rf <- individual_conditional_expectations(explainer_rf, new_apartment,
y = new_apartment$m2.price)
lce_rf
plot(lce_rf)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.