Elastic Net Regularization › Visualizing Elastic Net
Machine Learning from ScratchAll chapters Elastic Net Regularization › Visualizing Elastic NetOne section · Sections in this chapter3 / 8 ↓
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable









Row 1 - Ridge Regression (λ = 0.01, 0.1, 1.0): As the regularization parameter λ increases, all coefficients shrink toward zero but remain non-zero. Notice how correlated features 0 and 1 maintain similar coefficient values across all λ values. The coefficients become progressively smaller as λ increases, but no feature is ever eliminated.
Row 2 - LASSO (α = 0.01, 0.1, 1.0): As the regularization parameter α increases, LASSO performs automatic feature selection by driving some coefficients exactly to zero. Notice how LASSO might arbitrarily select one feature from the correlated pair (features 0 and 1) when α becomes large. The sparsity increases dramatically as α increases, with only the most important features remaining.
Row 3 - Elastic Net (α = 0.1, 0.5, 0.9): This row shows the mixing parameter α (l1_ratio) controlling the balance between L1 and L2 penalties. When α = 0.1, the model behaves more like Ridge, keeping most features with small coefficients. As α increases to 0.5 and 0.9, the L1 component becomes stronger, leading to more sparsity while still maintaining some stability for correlated features. Notice how features 0 and 1 tend to be kept together more consistently than in pure LASSO.

The side-by-side comparison reveals the basic trade-offs between these methods. Ridge (red bars) keeps all features with moderate coefficients. LASSO (blue bars) performs aggressive feature selection, setting some coefficients exactly to zero, but may arbitrarily choose between correlated features. Elastic Net (green bars) gives a balanced approach, maintaining some sparsity while preserving the grouping effect for correlated features. This makes Elastic Net particularly useful when you have correlated features and want both interpretability and stability.