Get startedGet started for free

Yeo-Johnson transformation

Using the attrition_num dataset with all numerical data about employees who have left the company, you want to build a model that can predict if an employee is likely to stay, using Attrition, a binary variable coded as a factor. To get the features to behave nearly normally, you will create a recipe that implements the Yeo-Johnson transformation.

The attrition_numdata, the logistic regression lr_model, the user-defined class-evaluate() function, and the trainand test splits are loaded for you.

This exercise is part of the course

Feature Engineering in R

View Course

Exercise instructions

  • Create a recipe that uses Yeo-Johnson to transform all numeric features, including the target.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Create a recipe that uses Yeo-Johnson to transform all numeric features
lr_recipe_YJ <- 
  recipe(Attrition ~., data = train) %>%
  ___

lr_workflow_YJ <- workflow() %>%
  add_model(lr_model) %>%
  add_recipe(lr_recipe_YJ)
lr_fit_YJ <- lr_workflow_YJ %>%
  fit(train)
lr_aug_YJ <-
  lr_fit_YJ %>% augment(test)
lr_aug_YJ %>% class_evaluate(truth = Attrition,
                 estimate = .pred_class,.pred_No)
Edit and Run Code