Skip to contents

Plot centered ICE profiles with centered PDP curves

Usage

g_ice(
  object,
  centered = TRUE,
  show_PDP = TRUE,
  coloured = FALSE,
  rug_sides = "b",
  missings_spec = missings_specification(),
  facet_spec = facet_specification(),
  logodds_to_prob = FALSE
)

Arguments

object

Object of classes rough and sculpture.

centered

logical, centered ice plots? Defaults to TRUE.

show_PDP

logical, show PDP line? Defaults to TRUE.

coloured

logical, coloured curves? Defaults to FALSE.

rug_sides

"" for none, "b", for bottom, "trbl" for all 4 sides (see geom_rug)

missings_spec

Object of class missings_specificatoin.

facet_spec

Object of class facet_specificatoin.

logodds_to_prob

(logical) Only valid for binary response and sculptures built on the log-odds scale. Defaults to FALSE (i.e. no effect). If TRUE, then the y-values are transformed through inverse logit function 1 / (1 + exp(-x)).

Value

List of ggplots (one for continuous features, one for discrete).

Examples

df <- mtcars
df$vs <- as.factor(df$vs)
model <- rpart::rpart(
  hp ~ mpg + carb + vs,
  data = df,
  control = rpart::rpart.control(minsplit = 10)
)
model_predict <- function(x) predict(model, newdata = x)
covariates <- c("mpg", "carb", "vs")
pm <- sample_marginals(df[covariates], n = 50, seed = 5)

rs <- sculpt_rough(
  dat = pm,
  model_predict_fun = model_predict,
  n_ice = 10,
  seed = 1,
  verbose = 0
)

g_ice(rs)$continuous