6.3 Practical Exercises: Chapter 6
In this exercise section, we’ll apply regularization techniques for feature selection using Lasso and Ridge. These exercises will help solidify your understanding of L1 and L2 regularization and hyperparameter tuning.
Exercise 1: Applying Lasso for Feature Selection
Objective: Use Lasso regression to identify the most important features from a dataset and observe how changing the alpha parameter affects feature selection.
Instructions:
Load a dataset with at least 15 features.
Apply Lasso regression and experiment with different values of alpha.
List the non-zero coefficients (selected features) for each alpha value and plot them to visualize which features remain relevant as alpha increases.
Solution: