What is Elastic Net regularization?
Last updated
Elastic net adds a weighted mix of L1 and L2 penalties to the loss. It keeps lasso's sparsity while adding ridge's stability and its tendency to group correlated features together.
Objective:
Loss + λ[α||β||₁ + (1−α)/2·||β||₂²].
λ sets the overall strength. α sets the mix: α = 1 is lasso, α = 0 is ridge.
In scikit-learn,
alphais λ andl1_ratiois α.
What the L1 part gives: Exact zeros, so the model performs feature selection.
What the L2 part gives:
Strict convexity, so the solution is unique even when p > n or features are collinear.
A grouping effect: highly correlated features get similar coefficients instead of lasso's arbitrary pick-one behavior.
It can select more than n features.
Practical notes:
Standardize features first, because both penalties are scale-sensitive.
The original "naive" elastic net (Zou & Hastie, 2005) shrinks twice, so the authors rescale coefficients by (1 + λ₂).
Fit with coordinate descent along a λ path (
glmnet,sklearn.linear_model.ElasticNet).