This function Local Conditional Expectation profiles

calculate_profiles_lce(data, variable_splits, model, dataset,
  predict_function = predict, ...)

Arguments

data

set of observations. Profile will be calculated for every observation (every row)

variable_splits

named list of vectors. Elements of the list are vectors with points in which profiles should be calculated. See an example for more details.

model

a model that will be passed to the predict_function

dataset

a data.frame, usually training data of a model, used for calculation of LCE profiles

predict_function

function that takes data and model and returns numeric predictions. Note that the ... arguments will be passed to this function.

...

other parameters that will be passed to the predict_function

Value

a data frame with profiles for selected variables and selected observations

Details

Note that calculate_profiles_lce function is S3 generic. If you want to work on non standard data sources (like H2O ddf, external databases) you should overload it.

Examples

library("DALEX")
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) vars <- c("construction.year", "surface", "floor", "no.rooms", "district") variable_splits <- calculate_variable_splits(apartments, vars) new_apartment <- apartments[1, ] profiles <- calculate_profiles_lce(new_apartment, variable_splits, apartments_rf_model, explainer_rf$data) profiles
#> m2.price construction.year surface floor no.rooms district _yhat_ #> 1 5897 1920 21.84884 3.087808 0.9151128 Srodmiescie 5450.533 #> 1.1 5897 1921 21.94433 3.085148 0.9176852 Srodmiescie 5490.713 #> 1.2 5897 1922 22.03982 3.082487 0.9202575 Srodmiescie 5485.823 #> 1.3 5897 1923 22.13531 3.079826 0.9228298 Srodmiescie 5498.118 #> 1.4 5897 1924 22.23080 3.077165 0.9254022 Srodmiescie 5509.683 #> 1.5 5897 1925 22.32629 3.074504 0.9279745 Srodmiescie 5477.263 #> _vname_ _ids_ #> 1 construction.year 1 #> 1.1 construction.year 1 #> 1.2 construction.year 1 #> 1.3 construction.year 1 #> 1.4 construction.year 1 #> 1.5 construction.year 1