เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Manual regularization with Lasso

The attrition dataset has 30 variables. Your Human Resources department asks you to build a model that is easy to interpret and maintain. They specifically want to reduce the number of features so that your model is as interpretable as possible.

In this exercise, you'll use Lasso to reduce the number of variables in your model automatically. In this first attempt, you will manually input a penalty and observe the model's behavior.

trainand test data, and a basic recipe are already loaded for you.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Feature Engineering in R

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Set your logistic regression model to use the glmnet engine.
  • Set arguments to run Lasso with a penalty of 0.06.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

model_lasso_manual <- logistic_reg() %>%

# Set the glmnet engine for your logistic regression model
  ___(___) %>%

# Set arguments to run Lasso with a penalty of 0.06
  set_args(mixture = ___, ___ = ___)

workflow_lasso_manual <- workflow() %>%
  add_model(model_lasso_manual) %>%
  add_recipe(recipe)

fit_lasso_manual <- workflow_lasso_manual %>% 
  fit(train)

tidy(fit_lasso_manual)
แก้ไขและรันโค้ด