model_profile: Dataset Level Variable Profile as Partial Dependence or...

Description Usage Arguments Details Value References Examples

View source: R/model_profile.R

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: https://pbiecek.github.io/ema/partialDependenceProfiles.html. The variable_profile function is a copy of model_profile.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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.

...

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

Details

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

Value

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

References

Explanatory Model Analysis. Explore, Explain and Examine Predictive Models. https://pbiecek.github.io/ema/

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
titanic_glm_model <- glm(survived~., data = titanic_imputed, family = "binomial")
explainer_glm <- explain(titanic_glm_model, data = titanic_imputed)
expl_glm <- model_profile(explainer_glm, "fare")
plot(expl_glm)

 ## 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)
expl_ranger <- model_profile(explainer_ranger)
plot(expl_ranger, geom = "profiles")

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

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

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

vp_ra <- model_profile(explainer_ranger, type = "accumulated")
plot(vp_ra, geom = "profiles")
 
## End(Not run)

DALEX documentation built on July 8, 2020, 7:17 p.m.

Related to model_profile in DALEX...