Create a polished model
sculpt_polished.Rd
Create a polished model
Arguments
- object
Object of class
sculpture
, eitherrough
ordetailed
.- k
Number of most important variables to keep.
- vars
Vector of variables to keep.
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)