Description Usage Arguments Value Examples
View source: R/calculate_weight.R
This function calculate an empirical density of raw data based on variable split from Ceteris Paribus profiles. Then calculated weight for values generated by DALEX::predict_profile()
, DALEX::individual_profile()
or ingredients::ceteris_paribus()
.
1 | calculate_weight(profiles, data, variable_split)
|
profiles |
|
data |
|
variable_split |
list generated by |
Return an weight based on empirical density.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | library("DALEX", warn.conflicts = FALSE, quietly = TRUE)
data(apartments)
split <- vivo::calculate_variable_split(apartments,
variables = colnames(apartments),
grid_points = 101)
library("randomForest", warn.conflicts = FALSE, quietly = TRUE)
apartments_rf_model <- randomForest(m2.price ~ construction.year + surface +
floor + no.rooms, data = apartments)
explainer_rf <- explain(apartments_rf_model, data = apartmentsTest[,2:5],
y = apartmentsTest$m2.price)
new_apartment <- data.frame(construction.year = 1998, surface = 88, floor = 2L, no.rooms = 3)
profiles <- predict_profile(explainer_rf, new_apartment)
library("vivo")
calculate_weight(profiles, data = apartments[, 2:5], variable_split = split)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.