Exercise

Create a recipe-model workflow

The tidymodels package can combine recipes and models into workflows. Workflows make it easy to create a pipeline of steps to prepare data and train models. Workflows can then be applied to new data easily, without having to redefine all the preprocessing and model building steps. Conveniently, workflows have a fit() function that fit both the recipe and the model to the data.

In this exercise, you will practice creating a recipe and a model and adding them to a workflow, so they are ready to be fit to the data. The train and test sets of the employee healthcare attrition data are available for your use. The target variable is Attrition.

The tidyverse and tidymodels packages have been loaded for you.

Instructions

100 XP
  • Define a recipe using the train data with a step_filter_missing(), step_scale(), and step_nzv() to remove NAs, scale the numeric features, and remove low-variance features, respectively. Use a threshold of 0.5 for step_filter_missing().
  • Define a logistic regression model using the "glm" engine.
  • Add feature_selection_recipe and lr_model to a workflow named attrition_wflow.