CommencerCommencer gratuitement

Who's staying?

It's time to practice combining several transformations to the attrition_num data. First, normalize or near-normalize numeric variables by applying a Yeo-Johnson transformation. Next, transform numeric predictors to percentiles, create dummy variables, and eliminate features with near zero variance.

Cet exercice fait partie du cours

Feature Engineering in R

Afficher le cours

Instructions

  • Apply a Yeo-Johnson transformation to all numeric variables.
  • Transform all numeric predictors into percentiles.
  • Create dummy variables for all nominal predictors.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

lr_recipe <- recipe(Attrition ~., data = train) %>%

# Apply a Yeo-Johnson transformation to all numeric variables
  ___ %>%

# Transform all numeric predictors into percentiles
 ___ %>%

# Create dummy variables for all nominal predictors
  ___

lr_workflow <- workflow() %>% add_model(lr_model) %>% add_recipe(lr_recipe)
lr_fit <- lr_workflow %>% fit(train)
lr_aug <- lr_fit %>% augment(test)
lr_aug %>% class_evaluate(truth = Attrition, estimate = .pred_class,.pred_No)
Modifier et exécuter le code