Regularization
馃Why Do We Need Regularization?
In machine learning, especially with complex models:
- The model may fit training data extremely well
- But perform poorly on new data → overfitting
馃憠 Regularization is a strategy to control model complexity and improve generalization.
馃摌What is Regularization?
馃敼 Definition
Regularization adds a penalty term to the learning objective to discourage overly complex models.
馃搻 Standard Learning Objective
Without regularization:
With regularization:
馃敡 General Form
Where:
- → model parameters
- → regularization strength
- → penalty function
馃幆 Role of 位 (Lambda)
- Small → slight penalty
- Large → strong constraint
馃憠 Controls bias–variance tradeoff
⚖️ Effect of Regularization
| Effect | Outcome |
|---|---|
| Reduces variance | Less overfitting |
| Increases bias | Slight underfitting possible |
| Shrinks coefficients | Simpler model |
⚖️Regularization and Generalization
Regularization helps:
- Reduce variance
- Improve generalization
- Control model complexity
馃攣 Bias–Variance Tradeoff
| Effect | Outcome |
|---|---|
| Increase regularization | ↑ Bias, ↓ Variance |
| Decrease regularization | ↓ Bias, ↑ Variance |
馃憠 Goal: optimal balance
馃搻 Mathematical Framework
馃敼 Standard Objective
Without regularization:
馃敼 With Regularization
Where:
- → loss function
- → regularization term
馃幆 Interpretation of 位
| 位 Value | Effect |
|---|---|
| 0 | No regularization |
| Small | Mild constraint |
| Large | Strong constraint (may underfit) |
馃ЗTypes of Regularization
馃敹L1 Regularization (LASSO)
馃搻 Penalty:
馃敼 Characteristics:
- Produces sparse models
- Some coefficients become exactly zero
- Performs feature selection
✅ Advantages:
- Interpretable models
- Useful for high-dimensional data
⚠️ Limitations:
- Unstable with correlated features
馃敺 L2 Regularization (Ridge)
馃搻 Penalty:
馃敼 Characteristics:
- Shrinks coefficients smoothly
- No exact zeros
✅ Advantages:
- Stable
- Handles multicollinearity well
馃煟 Elastic Net
馃搻 Combination:
馃敼 Characteristics:
- Combines L1 + L2
- Balances sparsity and stability
✅ Use case:
- When features are correlated
- When LASSO alone is unstable
馃尦 Regularization in Tree-Based Models
馃敼 Techniques:
- Max depth restriction
- Minimum samples per leaf
- Pruning
馃幆 Effect:
- Prevents overly complex trees
- Controls variance
馃 Regularization in Neural Networks
馃敼 1. Weight Decay
- Equivalent to L2 regularization
馃敼 2. Dropout
- Randomly deactivate neurons during training
Effect:
- Prevents co-adaptation
- Improves generalization
馃敼 3. Early Stopping
- Stop training when validation error increases
馃敼 4. Batch Normalization (Indirect)
- Stabilizes training
- Acts as mild regularizer
馃И Data-Based Regularization
馃敼 Data Augmentation
- Generate new training samples
- Common in image/text tasks
馃敼 Noise Injection
- Add noise to inputs or weights
馃搳 Geometric Interpretation
| Method | Shape | Effect |
|---|---|---|
| L1 | Diamond | Sparsity |
| L2 | Circle | Smooth shrinkage |
馃攳 Practical Workflow
- Split data (train/validation/test)
- Normalize features
- Choose regularization type
- Tune 位 using validation or cross-validation
- Evaluate on test set
馃摎 Theoretical Insight (Advanced Note)
From a probabilistic perspective:
| Regularization | Equivalent Prior |
|---|---|
| L1 | Laplace prior |
| L2 | Gaussian prior |
馃憠 Connects to Bayesian learning (important from Bishop)
馃幆 Role of Regularization in ML Systems
Regularization is critical for:
- High-dimensional datasets
- Deep learning models
- Noisy real-world data
- Preventing model instability
馃搳Summary Table
| Method | Key Idea | Effect |
|---|---|---|
| L1 (LASSO) | Absolute penalty | Sparse models |
| L2 (Ridge) | Squared penalty | Smooth shrinkage |
| Elastic Net | Combination | Balanced approach |
| Dropout | Random neuron removal | Robust NN |
| Early stopping | Stop training early | Avoid overfit |
| Tree pruning | Limit tree growth | Reduce variance |
馃幆Key Takeaways for Students
- Regularization controls model complexity
- Essential for good generalization
- L1 → feature selection
- L2 → stability
- 位 must be carefully tuned
Comments
Post a Comment