Exercise

Explore lasso regression penalty values

In the previous exercise, you completed all the code to scale the target and predictor variables. You will use the train data and lasso_recipe to build a workflow to train a lasso regression model and explore the effects of different penalty values. As you adjust the penalty and retrain the model, pay attention to the number of non-zero variables that are left in the model. You will be observing how lasso regression performs feature selection.

The tidyverse and tidymodels packages have been loaded for you.

Instructions

100 XP
  • Train a lasso regression workflow with a penalty of 0.001 and display the model coefficients that are greater than zero.
  • Re-train a lasso regression workflow with a penalty of 0.01 and display the model coefficients that are greater than zero.
  • Re-train a lasso regression workflow with a penalty of 0.1 and display the model coefficients that are greater than zero.