DALEX (version 2.2.0)

model_profile: Dataset Level Variable Profile as Partial Dependence or Accumulated Local Dependence Explanations

Description

This function calculates explanations on a dataset level set that explore model response as a function of selected variables. The explanations can be calulated as Partial Dependence Profile or Accumulated Local Dependence Profile. Find information how to use this function here: http://ema.drwhy.ai/partialDependenceProfiles.html. The variable_profile function is a copy of model_profile.

Usage

model_profile(
  explainer,
  variables = NULL,
  N = 100,
  ...,
  groups = NULL,
  k = NULL,
  center = TRUE,
  type = "partial"
)

variable_profile( explainer, variables = NULL, N = 100, ..., groups = NULL, k = NULL, center = TRUE, type = "partial" )

single_variable(explainer, variable, type = "pdp", ...)

Arguments

explainer

a model to be explained, preprocessed by the explain function

variables

character - names of variables to be explained

N

number of observations used for calculation of aggregated profiles. By default 100. Use NULL to use all observations.

...

other parameters that will be passed to ingredients::aggregate_profiles

groups

a variable name that will be used for grouping. By default NULL which means that no groups shall be calculated

k

number of clusters for the hclust function (for clustered profiles)

center

shall profiles be centered before clustering

type

the type of variable profile. Either partial, conditional or accumulated.

variable

deprecated, use variables instead

Value

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

Details

Underneath this function calls the partial_dependence or accumulated_dependence functions from the ingredients package.

References

Explanatory Model Analysis. Explore, Explain, and Examine Predictive Models. http://ema.drwhy.ai/

Examples

# NOT RUN {
titanic_glm_model <- glm(survived~., data = titanic_imputed, family = "binomial")
explainer_glm <- explain(titanic_glm_model, data = titanic_imputed)
model_profile_glm_fare <- model_profile(explainer_glm, "fare")
plot(model_profile_glm_fare)

 
# }
# NOT RUN {
library("ranger")
titanic_ranger_model <- ranger(survived~., data = titanic_imputed, num.trees = 50,
                               probability = TRUE)
explainer_ranger  <- explain(titanic_ranger_model, data = titanic_imputed)
model_profile_ranger <- model_profile(explainer_ranger)
plot(model_profile_ranger, geom = "profiles")

model_profile_ranger_1 <- model_profile(explainer_ranger, type = "partial",
                                        variables = c("age", "fare"))
plot(model_profile_ranger_1 , variables = c("age", "fare"), geom = "points")

model_profile_ranger_2  <- model_profile(explainer_ranger, type = "partial", k = 3)
plot(model_profile_ranger_2 , geom = "profiles")

model_profile_ranger_3  <- model_profile(explainer_ranger, type = "partial", groups = "gender")
plot(model_profile_ranger_3 , geom = "profiles")

model_profile_ranger_4  <- model_profile(explainer_ranger, type = "accumulated")
plot(model_profile_ranger_4 , geom = "profiles")

# Multiple profiles
model_profile_ranger_fare <- model_profile(explainer_ranger, "fare")
plot(model_profile_ranger_fare, model_profile_glm_fare)
 
# }
# NOT RUN {
# }