Gradient Descent (GD)

 

Gradient Descent (GD) 


๐Ÿ”น Definition

Gradient Descent is an iterative optimization algorithm used to find the minimum value of a function.

๐Ÿ‘‰ In Machine Learning, it is used to:

  • Minimize the loss (cost) function
  • Find optimal model parameters (coefficients)

๐Ÿ”น Key Idea

๐Ÿ‘‰ Move step-by-step in the direction where the function decreases fastest.

  • Gradient = slope of the function
  • We move in the opposite direction of the gradient

๐Ÿ”น 3. Mathematical Update Rule

ฮธnew=ฮธoldฮฑJ(ฮธ)\theta_{new} = \theta_{old} - \alpha \cdot \nabla J(\theta)

Where:

  • ฮธ\theta → parameter (coefficient)
  • ฮฑ\alpha → learning rate
  • J(ฮธ)\nabla J(\theta) → gradient of cost function

๐Ÿ”นSteps of Gradient Descent

  1. Initialize parameters (random or zero)
  2. Compute cost function
  3. Calculate gradient (derivative)
  4. Update parameters:

    ฮธ=ฮธฮฑgradient\theta = \theta - \alpha \cdot \text{gradient}
  5. Repeat until minimum is reached

Image credit: towards data science


๐Ÿ”น Conditions for Gradient Descent

Function should be:

  • Differentiable → derivative must exist
  • Convex → ensures global minimum

๐Ÿ”น Learning Rate (ฮฑ)

๐Ÿ‘‰ Controls step size

Learning RateEffect
Too small    Slow convergence
Too large    May diverge
Optimal    Fast convergence

๐Ÿ”นCost Function (Example: Linear Regression)

J(ฮธ)=(yy^)2J(\theta) = \sum (y - \hat{y})^2

๐Ÿ‘‰ GD minimizes this error


๐Ÿ”น Intuition

  • Think of rolling a ball downhill
  • It moves step-by-step to reach the lowest point

๐Ÿ”น When to Use

  • Large datasets
  • When closed-form solution (normal equation) is expensive
  • Used in:
    • Linear regression
    • Neural networks
    • Deep learning

๐Ÿ”น Advantages

  • Simple and easy to implement
  • Works well for large data

๐Ÿ”น Limitations

  • Can get stuck in local minima (non-convex case)
  • Sensitive to learning rate
  • Requires tuning

๐Ÿ”นSummary Formula

pn+1=pnฮฑf(pn)p_{n+1} = p_n - \alpha \nabla f(p_n)

๐Ÿ“ Quick Revision

  • Gradient = slope
  • Move opposite direction
  • Repeat until minimum
  • Learning rate is critical

Comments

Popular posts from this blog

Machine Learning PCCST503 Semester5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Machine Learning (ML)

Distinguishing Machine Learning from Traditional Programming