Problem 2: Observe Lasso Zeroing Out Coefficients
Easypython
Learn the Concept: Regularization (L1/L2)Problem Description
Write a Python program that trains a Lasso model with a sufficiently high alpha value on a dataset with some irrelevant features, and identifies which coefficients were shrunk to exactly zero.
Input
A dataset with some clearly irrelevant features (e.g., random noise).
Output
The learned coefficients, and which ones equal zero.
Constraints
- At least one feature should be essentially random/irrelevant.
Example Input
text(A dataset with 1 relevant feature and 1 random/irrelevant feature)
Example Output
textCoefficients: [2.5, 0.0] Zeroed-out features: [1]
Concepts Covered
Lasso, coefficient inspection, automatic feature selection.
Related Problems
- Problem 1: Compare Linear Regression, Ridge, and Lasso CoefficientsEasy · pythonSolve Problem
- Problem 3: Compare Different Alpha ValuesEasy · pythonSolve Problem
- Problem 4: Evaluate Regularized vs Unregularized Models on Test DataEasy · pythonSolve Problem