Fit the best model
lasso_grid contains 50 different model specs with 50 different penalty values in penalty_grid. In this exercise, you will find and fit the model with the optimal penalty value. In doing so, you will end up with a lasso regression model that optimizes feature selection for best model performance.
lasso_workflow and train are available for your use. The tidyverse and tidymodels packages have also been loaded for you.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Dimensionality Reduction in R
अभ्यास निर्देश
- Retrieve the best fitted model based on RMSE.
- Use
finalize_workflow()to fit a model based onbest_rmse. - Display of the model coefficients of
final_lasso.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Retrieve the best RMSE
best_rmse <- ___ %>%
___("___")
# Refit the model with the best RMSE
final_lasso <-
___(___, ___) %>%
fit(train)
# Display the non-zero model coefficients
tidy(___) %>%
filter(___ > ___)