vivo (version 0.1.0)

calculate_weight: Calculated empirical density and weight based on variable split.

Description

This function calculate an empirical density of raw data based on variable split from Ceteris Paribus profiles. Then calculated weight for values generated by ingredients::ceteris_paribus().

Usage

calculate_weight(profiles, data, variable_split)

Arguments

profiles

data.frame generated by ingredients::ceteris_paribus()

data

data.frame with raw data to model

variable_split

list generated by ingredients::calculate_variable_split()

Value

Return an weight based on empirical density.

Examples

Run this code
# NOT RUN {
library("DALEX", warn.conflicts = FALSE, quietly = TRUE)
data(apartments)

library("ingredients", warn.conflicts = FALSE, quietly = TRUE)
split <- calculate_variable_split(apartments, variables = colnames(apartments))

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 <- ceteris_paribus(explainer_rf, new_apartment)

library("vivo")
calculate_weight(profiles, data = apartments[, 2:5], variable_split = split)


# }

Run the code above in your browser using DataLab