Dataset Level Variable Effect as Partial Dependency Profile or Accumulated Local Effects
Dataset Level Variable Effect as Partial Dependency Profile or Accumulated Local Effects
From DALEX version 1.0 this function calls the accumulated_dependence or partial_dependence from the ingredients package. Find information how to use this function here: https://ema.drwhy.ai/partialDependenceProfiles.html.
variable_effect(explainer, variables,..., type ="partial_dependency")variable_effect_partial_dependency(explainer, variables,...)variable_effect_accumulated_dependency(explainer, variables,...)
Arguments
explainer: a model to be explained, preprocessed by the 'explain' function
variables: character - names of variables to be explained
...: other parameters
type: character - type of the response to be calculated. Currently following options are implemented: 'partial_dependency' for Partial Dependency and 'accumulated_dependency' for Accumulated Local Effects
Returns
An object of the class 'aggregated_profiles_explainer'. It's a data frame with calculated average response.
Examples
titanic_glm_model <- glm(survived~., data = titanic_imputed, family ="binomial")explainer_glm <- explain(titanic_glm_model, data = titanic_imputed)expl_glm <- variable_effect(explainer_glm,"fare","partial_dependency")plot(expl_glm)library("ranger")titanic_ranger_model <- ranger(survived~., data = titanic_imputed, num.trees =50, probability =TRUE)explainer_ranger <- explain(titanic_ranger_model, data = titanic_imputed)expl_ranger <- variable_effect(explainer_ranger, variables ="fare", type ="partial_dependency")plot(expl_ranger)plot(expl_ranger, expl_glm)# Example for factor variable (with factorMerger)expl_ranger_factor <- variable_effect(explainer_ranger, variables ="class")plot(expl_ranger_factor)
References
Explanatory Model Analysis. Explore, Explain, and Examine Predictive Models. https://ema.drwhy.ai/