Lasso picks one of two nearly-identical predictors and throws the other away — but which one it keeps can be an arbitrary accident of the data, not a meaningful choice. What if you wanted the sparsity of lasso, but without that fragile all-or-nothing bet on correlated features?
Same two correlated predictors as the last two chapters, same total penalty strength — only the mix between L1 and L2 changes. At α=1 it's pure lasso: sits at exact zero. Slide α down and watch revive, smoothly, long before you reach pure ridge.
ElasticNet's penalty is a weighted blend of both:
- — the total penalty strength, same role as in ridge and lasso.
- — the mixing parameter, between 0 and 1: is pure lasso, is pure ridge.
- , — the L1 and L2 penalty terms from the last two chapters, now combined.
- Each coordinate update generalizes both single-penalty rules
Coordinate descent still soft-thresholds by the L1 share of the penalty, then divides by the data term plus the L2 share — set and the L2 share vanishes, recovering lasso's update exactly; set and the soft-threshold cutoff vanishes, recovering a ridge-like update.
- The L2 term restores ridge's grouping effect
Even a small amount of L2 ( just under 1) is enough to stop lasso's arbitrary all-or-nothing choice between correlated predictors — both stay in the model, sharing the fit instead of one evicting the other.
- The L1 term keeps sparsity available
Push close enough to 1 and the sparsity comes back — ElasticNet doesn't have to choose between "shrinks everything" and "zeros out weak predictors"; dials between them.
Drag α down from 1. Somewhere before you reach 0, stops being exactly zero and starts climbing — that's the L2 term's grouping effect outweighing L1's corner.
Same toy setup as ridge and lasso: , , , fixed .
- α = 1 (pure lasso): sparse, as expected
Pure L1: the L1 share is , the L2 share is . One coordinate-descent round from :
- (since ), so soft-thresholding gives
- — inside the dead zone , so exactly
Plugging back into step 1 reproduces the same , so this is already the fixed point — no further rounds change anything.
- α = 0.5: both predictors survive, close together
Now the L1 share is and the L2 share is also . One round from :
- , so
- , so
Unlike , this isn't a fixed point yet — repeating the same two-line cycle (recompute with the latest , then with the latest ) nudges both weights further each round, converging to , — no longer sparse, but the two nearly-collinear predictors are now sharing credit almost the way ridge would.
- α = 0 (pure ridge): fully grouped
Now the L1 share is (no soft-thresholding) and the L2 share is . One round from :
- , so
- , so
Repeating that same cycle converges to , — about as close together as ridge alone would produce (a differently-scaled λ than the closed-form ridge chapter, since this loss averages the squared error instead of summing it — but the qualitative grouping behavior matches).
Lower α from pure lasso until w₂ climbs back above 0.5 — enough L2 influence to bring the zeroed predictor back into the model.
ElasticNet doesn't pick a side between L1 and L2 — it interpolates. Lasso's sparsity stays available near , and even a little L2 mixed in restores ridge's grouping effect on correlated predictors, fixing the exact fragility that pure lasso has no way to fix on its own.