10.9 R demonstration structure

The exact package can vary, but the workflow should preserve the separation between training, tuning, and final evaluation.

library(tidymodels)

set.seed(490)
split <- initial_split(member_model_data, strata = retained_12m)
train_data <- training(split)
test_data  <- testing(split)

retention_recipe <- recipe(retained_12m ~ ., data = train_data) |>
  step_unknown(all_nominal_predictors()) |>
  step_dummy(all_nominal_predictors()) |>
  step_normalize(all_numeric_predictors())

Preprocessing steps must be estimated from training data. The final test set should remain untouched until method and tuning decisions are complete.