Partial Dependency Profiles are averages from Ceteris Paribus Profiles.
Function `partial_dependency`

calls `ceteris_paribus`

and then `aggregate_profiles`

.

partial_dependency(x, ...) # S3 method for explainer partial_dependency(x, variables = NULL, N = 500, variable_splits = NULL, grid_points = 101, ..., variable_type = "numerical") # S3 method for default partial_dependency(x, data, predict_function = predict, label = class(x)[1], variables = NULL, grid_points = 101, variable_splits = NULL, N = 500, ..., variable_type = "numerical") # S3 method for ceteris_paribus_explainer partial_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. |

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 |

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 Partial Dependence Profiles Chapter.

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) pdp_glm <- partial_dependency(explain_titanic_glm, N = 50, variables = c("age", "fare")) head(pdp_glm)#> Top profiles : #> _vname_ _label_ _x_ _yhat_ _ids_ #> 1 fare lm 0.0000000 0.3433783 0 #> 2 age lm 0.1666667 0.4136692 0 #> 3 age lm 2.0000000 0.4112289 0 #> 4 age lm 4.0000000 0.4085750 0 #> 5 fare lm 6.1793080 0.3512579 0 #> 6 age lm 7.0000000 0.4046102 0plot(pdp_glm)# \donttest{ library("randomForest") model_titanic_rf <- randomForest(survived ~., data = titanic_imputed)#> 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) pdp_rf <- partial_dependency(explain_titanic_rf, variable_type = "numerical") plot(pdp_rf)pdp_rf <- partial_dependency(explain_titanic_rf, variable_type = "categorical") plotD3(pdp_rf, variable_type = "categorical", label_margin = 80, scale_plot = TRUE) # }