Skip to contents

Create a polished model

Usage

sculpt_polished(object, k = NULL, vars = NULL)

Arguments

object

Object of class sculpture, either rough or detailed.

k

Number of most important variables to keep.

vars

Vector of variables to keep.

Value

Object of classes rough / detailed and sculpture.

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
)

ds <- sculpt_detailed_gam(rs)

# this keeps only "mpg"
ps <- sculpt_polished(ds, k = 1)