Subdomain 1.3: Regularization, L1, L2, Elasticnet
1.Which of the following statements accurately describe the mathematical and practical differences between L1 and L2 regularization in scikit-learn?(Select 3)
- A.L1 regularization adds a penalty equal to the absolute value of the magnitude of coefficients.
- B.L2 regularization can yield exact zero coefficients, performing implicit feature selection.
- C.L2 regularization adds a penalty equal to the square of the magnitude of coefficients.
- D.ElasticNet is a linear combination of L1 and L2 penalties.
- E.L1 regularization is strictly preferred over L2 when features are highly collinear.
- F.The Ridge estimator uses L1 regularization.
Show answer & explanation
Correct answers: A, C, D — L1 regularization adds a penalty equal to the absolute value of the magnitude of coefficients.; L2 regularization adds a penalty equal to the square of the magnitude of coefficients.; ElasticNet is a linear combination of L1 and L2 penalties.
- A. Correct. L1 regularization (Lasso) adds a penalty proportional to the sum of the absolute values of the coefficients. This penalty encourages sparsity in the model, often driving some coefficients exactly to zero, which enables implicit feature selection.
- B. Incorrect. L1 regularization, not L2, yields exact zero coefficients. L2 regularization (Ridge) shrinks coefficients toward zero but they rarely become exactly zero, as the penalty is proportional to the square of the weights.
- C. Correct. L2 regularization (Ridge) adds a penalty proportional to the square of the magnitude of the coefficients. This effectively penalizes larger weights more heavily than smaller ones, leading to smaller, more stable coefficients, which is particularly useful for handling multicollinearity.
- D. Correct. ElasticNet combines L1 and L2 penalties into a single objective function. In scikit-learn, this balance is controlled by the 'l1_ratio' parameter, allowing the user to benefit from both the sparsity of L1 and the grouping effects/stability of L2.
- E. Incorrect. L1 regularization can be unstable when features are highly collinear, often picking one feature at random from a group of correlated features. L2 regularization (or ElasticNet) is generally preferred in these scenarios as it distributes weights across all correlated features.
- F. Incorrect. In scikit-learn, the Ridge estimator is specifically designed for L2 regularization. The Lasso estimator is the one that implements L1 regularization.