Skip to content

Visualizing gradient descent in Python to build understanding of how it works - concept learned from Andrew Ng’s Machine Learning course on Coursera.

Notifications You must be signed in to change notification settings

Zaymerstone/gradient_descent_visualization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Gradient Descent Intuition Visualization

A Python script to visually and mathematically understand the concept of gradient descent, implemented as part of my ongoing learning in machine learning and AI field.
This repo demonstrates how core optimization concepts can be understood through both code and visualization.


🚀 Overview

This script was created after following the Machine Learning Specialization by Andrew Ng on Coursera (Machine Learning Specialization), as part of my journey to transition from full-stack development to Machine Learning / AI development.

Key points:

  • Educational Purpose: The goal was to develop an intuitive understanding of gradient descent, its mathematical and visual parts.
  • Core Concepts Practiced:
    • Gradient computation and application
    • Iterative solution updates
    • Learning rate effect on convergence
    • Visualizing optimization paths on objective functions
  • Mathematical Foundation: Reinforces understanding of supervised learning, linear regression, and optimization methods.
  • Visualization: Steps of the gradient descent algorithm are plotted alongside randomly sampled points from the objective function to observe convergence.

This helped me to translate this mathematical concept into functional code, bridging my software engineering skills with begginer machine learning knowledge.


🛠️ Tech Stack

  • Python 3
  • NumPy for numerical computations
  • Matplotlib for data visualization

📄 Features

  • Objective function definition (x²)
  • Gradient (derivative) computation
  • Random sampling for visualization
  • Gradient descent iterative optimization
  • Plot showing random samples and gradient descent steps
  • Console output of each iteration for clarity

📚 How to Run the Script

  1. Clone the repository
git clone https://github.com/Zaymerstone/cogsup-prog.git
  1. Install dependencies
    pip install numpy matplotlib
    
  2. Run the script
    python gradient_descent_visualization.py
    
  • Observe the console output showing iterative optimization steps
  • Check the plot showing the random samples and the trajectory of gradient descent

📈 What I Learned

  • The logics behind gradient descent algorithm and how exactly it works
  • Effect of learning rate and what happens if we increase / decrease it
  • Taking my first steps into Machine Learning and AI development

👤 Author

Nesterov Egor
BSc in Computer Science
Aspiring Machine Learning / AI Developer

Contact:

About

Visualizing gradient descent in Python to build understanding of how it works - concept learned from Andrew Ng’s Machine Learning course on Coursera.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages