- Introduced by
- Zou, H. & Hastie, T.
- Year
- 2005
- Type
- Regularized linear regression (L1 + L2 penalty)
What does it do?
Elastic Net is a regularized linear regression method introduced by Zou and Hastie in 2005.
It combines the LASSO (L1) and Ridge (L2) penalties, so it performs variable selection and coefficient shrinkage at the same time. It was developed for settings with many predictors, especially correlated ones, where the LASSO alone was reported to be less satisfactory.
The intuition behind the method
Plain linear regression can overfit and behaves badly when predictors are correlated or there are more features than observations. LASSO can zero out coefficients to select variables but struggles when groups of predictors are correlated, while Ridge shrinks everyone smoothly but never drops a variable. Elastic Net mixes the two: it keeps LASSO's ability to set some coefficients exactly to zero while borrowing Ridge's stability so that correlated predictors are handled gracefully instead of being chosen arbitrarily.
History
Hui Zou and Trevor Hastie introduced the Elastic Net in 2005 in the Journal of the Royal Statistical Society: Series B. The paper's abstract reports that the LASSO is not very satisfactory for variable selection when predictors far outnumber observations, and that the Elastic Net often outperforms the LASSO while keeping a similar sparsity. By adding an L2 term to the L1 penalty, the authors obtained the grouping effect, and they proposed the LARS-EN algorithm to compute its regularization paths.
When to use it
Consider Elastic Net when you need prediction or explanation, you have many predictors (particularly correlated ones, or more predictors than observations), and you want variable selection and shrinkage together. The formulation shown in the mechanics is a squared-error loss on a linear predictor, so it fits continuous outcomes under an approximately linear relationship. The same elastic net penalty can be applied to other linear-model losses, for example the logistic loss for binary outcomes in regularized logistic regression, with the loss changed accordingly. Avoid it when the sample is too small to tune two hyperparameters reliably; a single-penalty model (LASSO if you need selection only, Ridge if you need shrinkage only) is then simpler. Do not use it when the main goal is unbiased effect estimation with valid inference, because the penalty deliberately biases coefficients.
Limitations and considerations
- The loss in the formula is squared error on a linear predictor, so the method as specified applies to continuous outcomes with an approximately linear relationship.
- The L1 and L2 terms act on coefficient magnitudes, so predictors on different scales are penalized unequally unless they are standardized first.
- Two hyperparameters (λ and α) must be chosen; with limited data this search is less reliable than tuning a single penalty.
- Coefficients are shrunk, and the set of retained variables can change with the tuning choice, so the selected model should be checked for sensitivity.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Combines LASSO-style selection (the L1 term) and Ridge-style shrinkage (the L2 term) in one penalty, with α setting the balance.
- Exhibits a grouping effect: strongly correlated predictors tend to enter or leave the model together rather than one being picked more or less arbitrarily.
- Designed for the case where predictors greatly outnumber observations, a setting in which the original paper reports the LASSO to be less satisfactory.
- For the squared-error elastic net, the LARS-EN algorithm of Zou and Hastie (2005) computes the regularization path efficiently, in the same spirit as LARS does for the LASSO.
- The penalty can be used with any linear model, including regression and classification.
Applications
- Regression with many predictors, where the number of predictors exceeds the number of observations.
- Genomic and biomarker studies in which many predictors are strongly correlated.
- Predictive models that need both variable selection and shrinkage of the retained coefficients.
- Explanatory models with correlated predictors: because correlated predictors are retained or dropped together, the result can suggest that a group contributes signal, but it does not establish which member is causal or that any single member carries the effect alone, and the coefficients are biased.
How it works
How it works
The model is y = β0 + Xβ + error. The slope coefficients are chosen to minimize a squared-error loss, written with a 1/(2n) scaling, plus a combined penalty. The intercept β0 is not penalized; only the slope coefficients are shrunk. The L1 term, with weight α, can set coefficients exactly to zero, which performs selection. The L2 term, with weight (1−α)/2, shrinks coefficients smoothly. The overall penalty strength is set by λ, and α sets the balance between the two terms: α = 1 leaves only the L1 (LASSO) penalty, and α = 0 leaves only the L2 (Ridge) penalty. This is the standardized parameterization used in common software (for example glmnet). Zou and Hastie (2005) write the same penalty as λ1 times the L1 norm plus λ2 times the squared L2 norm, so λ and α are a reparameterization of their λ1 and λ2.
Formula
\min_{\beta}\; \tfrac{1}{2n}\,\lVert y - X\beta \rVert_2^2 + \lambda\left( \alpha \lVert\beta\rVert_1 + \tfrac{1-\alpha}{2}\lVert\beta\rVert_2^2 \right)Two hyperparameters govern the fit: the overall penalty strength λ and the mixing parameter α (written l1_ratio in some software). They are usually chosen by cross-validation over a grid of both values. In some applications α is instead fixed beforehand on qualitative grounds and only λ is tuned. Because the search has two dimensions, the chosen values can be unstable when the sample is small, so the sensitivity of the result to the grid should be checked. Predictors should be standardized first so that the penalty treats every feature on a comparable scale.
The fitted model returns a sparse set of coefficients: predictors with little support are driven exactly to zero and dropped, while strongly correlated predictors tend to be kept or removed together. The surviving coefficients are shrunk toward zero, which can give more stable predictions than unpenalized regression on the same features, but they are not unbiased estimates of effect sizes.
Common pitfalls
- Fitting without standardizing the predictors, which makes the penalty depend on the units of each variable.
- Choosing λ and α by cross-validation on a small sample and reporting the result without checking how sensitive it is to the grid.
- Using Elastic Net when a single penalty answers the question. Setting α = 1 gives the LASSO penalty and α = 0 gives the Ridge penalty, so the choice of α is itself a decision to justify.
- Reading the retention of one predictor from a correlated group as proof that it alone carries the signal, when the grouping effect means correlated predictors are kept or dropped together.
- Interpreting shrunken coefficients as unbiased effect sizes.
Frequently asked questions
How is Elastic Net different from LASSO and Ridge?
LASSO uses only the L1 penalty, which performs selection but is less satisfactory when predictors are highly correlated or greatly outnumber observations. Ridge uses only the L2 penalty, which gives stable shrinkage but never sets coefficients to zero. Elastic Net blends both, controlled by the mixing parameter α, so it selects variables and handles correlated groups of features.
Do I need to scale my features?
Yes. The penalty acts on the size of the coefficients, so features should be standardized first; otherwise predictors on large scales are penalized differently and the selection is biased toward or against them.
How many observations do I need?
The original paper does not give a sample-size threshold. The practical concern is that two hyperparameters must be tuned by cross-validation, which is unreliable on small samples. With very few observations, a single-penalty model is the simpler choice.
What do the two hyperparameters control?
The overall penalty strength λ controls how much the coefficients are shrunk, and the mixing parameter α sets the balance between the L1 selection penalty and the L2 shrinkage penalty. Both are usually chosen by cross-validation.
Related methods
Sources
Zou, H. & Hastie, T. (2005). Regularization and Variable Selection via the Elastic Net. Journal of the Royal Statistical Society: Series B, 67(2), 301–320.
Open DOI reference