`R/accumulated_dependency.R`

`accumulated_dependency.Rd`

Accumulated Local Effects Profiles accumulate local changes in Ceteris Paribus Profiles.
Function `accumulated_dependency`

calls `ceteris_paribus`

and then `aggregate_profiles`

.

accumulated_dependency(x, ...) # S3 method for explainer accumulated_dependency(x, variables = NULL, N = 500, variable_splits = NULL, grid_points = 101, ..., variable_type = "numerical") # S3 method for default accumulated_dependency(x, data, predict_function = predict, label = class(x)[1], variables = NULL, N = 500, variable_splits = NULL, grid_points = 101, ..., variable_type = "numerical") # S3 method for ceteris_paribus_explainer accumulated_dependency(x, ..., variables = NULL)

x | an explainer created with function |
---|---|

... | other parameters |

variables | names of variables for which profiles shall be calculated.
Will be passed to |

N | number of observations used for calculation of partial dependency profiles. By default, 500 observations will be chosen randomly. |

variable_splits | named list of splits for variables, in most cases created with |

grid_points | number of points for profile. Will be passed to |

variable_type | a character. If "numerical" then only numerical variables will be calculated. If "categorical" then only categorical variables will be calculated. |

data | validation dataset Will be extracted from |

predict_function | predict function Will be extracted from |

label | name of the model. By default it's extracted from the |

an object of the class `aggregated_profiles_explainer`

Find more detailes in the Accumulated Local Dependency Chapter.

ALEPlot: Accumulated Local Effects (ALE) Plots and Partial Dependence (PD) Plots https://cran.r-project.org/package=ALEPlot, Predictive Models: Visual Exploration, Explanation and Debugging https://pbiecek.github.io/PM_VEE

library("DALEX")#>#>model_titanic_glm <- glm(survived ~ gender + age + fare, data = titanic_imputed, family = "binomial") explain_titanic_glm <- explain(model_titanic_glm, data = titanic_imputed[,-8], y = titanic_imputed[,8], verbose = FALSE) adp_glm <- accumulated_dependency(explain_titanic_glm, N = 150, variables = c("age", "fare")) head(adp_glm)#> Top profiles : #> _vname_ _label_ _x_ _yhat_ _ids_ #> age.lm.0.1666666667 age lm 0.1666667 0.000000000 0 #> age.lm.2 age lm 2.0000000 -0.002560580 0 #> age.lm.4 age lm 4.0000000 -0.005345283 0 #> age.lm.7 age lm 7.0000000 -0.009508252 0 #> age.lm.9 age lm 9.0000000 -0.012273672 0 #> age.lm.13 age lm 13.0000000 -0.017795000 0plot(adp_glm)#>#>#> Warning: The response has five or fewer unique values. Are you sure you want to do regression?explain_titanic_rf <- explain(model_titanic_rf, data = titanic_imputed[,-8], y = titanic_imputed[,8], verbose = FALSE) adp_rf <- accumulated_dependency(explain_titanic_rf, N = 200, variable_type = "numerical") plot(adp_rf)adp_rf <- accumulated_dependency(explain_titanic_rf, N = 200, variable_type = "categorical") plotD3(adp_rf, variable_type = "categorical", label_margin = 80, scale_plot = TRUE) # }