Simple Linear Regression using Gradient Descent
Simple Linear Regression using Gradient Descent
🔹 1. Model (Hypothesis)
In simple linear regression:
Where:
- → intercept
- → slope
🔹 2. Cost Function (MSE)
We minimize the Mean Squared Error (MSE):
👉 The factor simplifies derivatives.
🔹 3. Goal
👉 Find and that minimize
🔹 4. Compute Gradients (Very Important)
We take partial derivatives:
🔸 Derivative w.r.t
🔸 Derivative w.r.t
🔹 5. Update Rules
Using Gradient Descent:
🔸 Update
🔸 Update
🔹 6. Algorithm Steps
📌 Gradient Descent Procedure
- Initialize (0 or small random values)
-
Compute predictions:
-
Compute error:
- Compute gradients
- Update parameters
- Repeat until convergence
🔹 7. Intuition
- If prediction is too small → increase parameters
- If prediction is too large → decrease parameters
👉 Gradually moves toward best-fit line
🔹 8. Why Use Gradient Descent?
- Works for large datasets
- Avoids matrix inversion
- Scales well
🔹 9. Convergence
Stops when:
- Cost function stops decreasing
- Maximum iterations reached
🔹 10. Important Notes
- Learning rate is critical
- Feature scaling improves performance
- Works even when closed-form solution is expensive
🔹 11. Summary
| Step | Description |
|---|---|
| Model | |
| Cost | MSE |
| Method | Iterative optimization |
| Update | Move opposite gradient |
Comments
Post a Comment