Skip to contents

Create a detailed model with gam smoother

Usage

sculpt_detailed_gam(rs, missings = NULL, verbose = 0, allow_par = FALSE)

Arguments

rs

Rough model, i.e. object of classes rough and sculpture.

missings

(NULL) or single value or a named vector. Specifies the value(-s) that stand for the missing values. If NULL, then no missing value handling is carried out. If single value, then it is assumed that this value is used for flagging missing values across all continuous variables. If named vector, then the names are used to refer to continuous variables and the values for flagging missing values in that variable.

verbose

(integer) 0 for silent run, > 0 for messages.

allow_par

(logical) Allow parallel computation? Defaults to FALSE.

Value

Object of classes detailed and sculpture.

Details

For parallel computation, use parallel_set() and set allow_par to TRUE. Note that parallel computation may fail if the model is too big and there is not enough memory.

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)
class(ds)
#> [1] "detailed"  "sculpture" "list"