Loss Function and Optimization in Supervised Learning
Loss Function and Optimization in Supervised Learning
🔹 Overview
In supervised learning, we want to learn a function:
👉 The key questions:
- How good is the prediction? → Loss Function
- How do we improve the model? → Optimization
🔹Loss Function
🔹Definition
A loss function measures the difference between actual output and predicted output.
Where:
- → true value
- → predicted value
🔹Role of Loss Function
👉 It acts as a guide for learning
- Quantifies error
- Provides objective for optimization
- Helps compare models
🔹Types of Loss Functions
🟦 1. Regression Loss Functions
📌 Mean Squared Error (MSE)
- Penalizes large errors
- Smooth and differentiable
📌 Mean Absolute Error (MAE)
- Robust to outliers
🟩 2. Classification Loss Functions
📌 0–1 Loss
📌 Cross-Entropy Loss (Very Important)
- Used in logistic regression and neural networks
📌 Hinge Loss (SVM)
🔹 Properties of Good Loss Functions
- Differentiable
- Convex (for easy optimization)
- Reflects real-world cost
🔹Optimization
🔹 Definition
Optimization is the process of finding model parameters that minimize the loss function.
🔹 Objective Function
🔹 Gradient Descent
📌 Idea:
Move parameters in direction of steepest decrease of loss
Where:
- → learning rate
- → gradient
🔹 Types of Gradient Descent
🟦 1. Batch Gradient Descent
- Uses entire dataset
🟩 2. Stochastic Gradient Descent (SGD)
- Uses one data point
🟨 3. Mini-Batch Gradient Descent
- Uses small subsets
🔹Learning Rate (Very Important)
- Too small → slow learning
- Too large → divergence
🔹 Convergence
👉 Optimization stops when:
- Loss stops decreasing
- Gradient ≈ 0
🔹 Local vs Global Minimum
- Global minimum → best solution
- Local minimum → suboptimal
🔹 Regularization (Connected to MAP)
Add penalty to avoid overfitting:
🔹Connection Between Loss and Optimization
👉 Loss defines what to minimize
👉 Optimization defines how to minimize
🔹Example
📌 Linear Regression
Model:
Loss:
Optimization:
- Use gradient descent
- Update
🔹Practical Challenges
- Non-convex loss (neural networks)
- Large datasets
- Vanishing gradients
🔹Key Insights
- Learning = optimization problem
- Choice of loss affects model behavior
- Efficient optimization is crucial for large-scale data
- Trade-off between accuracy and computational cost
📝 Summary
Loss Function:
- Measures prediction error
- Defines objective
Optimization:
- Minimizes loss
- Finds best parameters
Comments
Post a Comment