CAB212 · Unit 2: Regression
Regularization: ridge, lasso and elastic net
8 practice questions
Key points
- Ridge = L2, lasso = L1
- Lasso can zero out weights
- Larger lambda: more bias, less variance
- Standardize features first
Regularization adds a penalty on weight size to the loss to reduce overfitting.
| Method | Penalty | Effect |
|---|---|---|
| Ridge (L2) | lambda * sum(w^2) | Shrinks weights toward zero, rarely exactly zero |
| Lasso (L1) | lambda * sum(|w|) | Drives some weights to exactly zero (feature selection) |
| Elastic net | Mix of L1 and L2 | Handles correlated features; keeps sparsity |
The hyperparameter lambda (alpha in scikit-learn) sets strength: lambda = 0 gives plain OLS; large lambda shrinks weights heavily (more bias, less variance).
The intercept is normally not penalized. Features should be standardized first because penalties depend on weight scale.
Exam pitfall: lasso produces sparse models; ridge does not.
Try two questions
Lasso is useful for automatic:
- Data splitting
- Feature selection
- Label encoding
- Image resizing
Show the answer
B. Zeroed weights drop features.
The ridge penalty is proportional to:
- The number of samples
- The sum of absolute weights
- The sum of squared weights
- The product of weights
Show the answer
C. Ridge is L2 regularization.