Both add a penalty on coefficient size to the loss to discourage overfitting.
L1 (Lasso) penalizes the sum of absolute weights; it drives some weights to exactly zero, so it performs feature selection and gives sparse models.
L2 (Ridge) penalizes the sum of squared weights; it shrinks all weights smoothly toward zero without zeroing them, and handles correlated features well.
Elastic Net mixes both. The penalty strength (lambda or alpha) is a hyperparameter tuned with cross-validation.
Loading…