Get startedGet started for free

Normalizing and log-transforming

You are handed a dataset, attrition_num with numerical data about employees who left the company. Features include Age, DistanceFromHome, and MonthlyRate.

You want to use this data to build a model that can predict if an employee is likely to stay, denoted by Attrition, a binary variable coded as a factor. In preparation for modeling, you want to reduce possible skewness and prevent some variables from outweighing others due to variations in scale.

The attrition_numdata and the trainand test splits are loaded for you.

This exercise is part of the course

Feature Engineering in R

View Course

Exercise instructions

  • Normalize all numeric predictors.
  • Log-transform all numeric features, with an offset of one.

Hands-on interactive exercise

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

lr_model <- logistic_reg()

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

# Normalize all numeric predictors
  ___(all_numeric_predictors()) %>%

# Log-transform all numeric features, with an offset of one
  ___(___, offset = ___)

lr_workflow <- 
  workflow() %>%
  add_model(lr_model) %>%
  add_recipe(lr_recipe)

lr_workflow
Edit and Run Code