This project aims to quantify my skills in AI and Machine Learning (ML) by visualizing various algorithms. Specifically, I focus on linear regression through gradient descent. The core learning comes from following the Stanford CS229: Machine Learning | Summer 2019 lecture series by Dr. Anand Avati, alongside supplemental knowledge gained from the "Neural Networks and Deep Learning" course by Andrew Ng, part of the Deep Learning Specialization by deeplearning.ai.
The purpose of this project is to apply the theoretical concepts learned through these courses and visualize them using the R programming language, Plotly, and the built-in Iris dataset. The project aims to provide insight into linear regression models, gradient descent optimization, loss functions, and their graphical representations.
- Learn and implement the theory of linear regression and gradient descent.
- Visualize key concepts such as the cost function, gradient descent, and regression performance using interactive 2D and 3D plots.
- Use R and Plotly for generating the visualizations.
- Utilize the Iris dataset to demonstrate the linear regression process and its effectiveness.
Linear regression is a supervised machine learning algorithm used to model the relationship between a dependent variable and one or more independent variables. The goal is to fit a linear equation to observed data, allowing predictions to be made for future or unseen data.
In this project, linear regression is implemented using gradient descent optimization to minimize the cost function, which is the average squared difference between the predicted and actual values.
The process of linear regression and gradient descent is illustrated in the following steps:
- Data Preprocessing: Data is loaded, cleaned, and normalized for the regression model.
- Model Training: A linear regression model is fit to the Iris dataset using gradient descent.
- Visualization: Various visualizations (2D/3D) are generated to help understand the cost function and regression performance.
- Evaluation: The final regression model is evaluated by comparing its predictions against actual data points.
This project explores linear regression using gradient descent for machine learning applications. By applying theory from the Stanford CS229 lecture series and the Deep Learning Specialization, I aim to visualize important concepts such as loss functions, gradient descent, and the performance of linear regression on the Iris dataset. Key visualizations include cost function surfaces, gradient descent paths, and regression line plots. The project is implemented in R and uses Plotly for interactive 2D and 3D plots.
To run this project locally, clone the repository and install the necessary dependencies.
git clone https://github.com/adlikestocode/machinelearningalgorithmsvisualised.git
cd machinelearningalgorithmsvisualised
Install required R packages:
install.packages(c("plotly", "ggplot2", "dplyr"))
- Open the project folder and run the
linear_regression.Rmd
R Markdown file. - This will generate the visualizations and outputs in HTML format, including interactive plots for the cost function and gradient descent process.
In this project, you will see the following visualizations:
- 3D Surface Plot of the Cost Function: A 3D representation of the cost function as it changes with parameters
theta0
andtheta1
. - Gradient Descent Path: A 2D heatmap showing the path followed by gradient descent during training, with parameters updated at each step.
- Regression Line: A plot comparing the predicted regression line with actual data points from the Iris dataset.
These visualizations help to understand how the gradient descent algorithm minimizes the cost function to find the optimal parameters for the regression model.
- Linear Regression in Machine Learning - GeeksforGeeks
- Stanford CS229: Machine Learning | Summer 2019 | Lecture 4 - Linear Regression
- Deep Learning | Coursera
- Udemy YouTube 16x9 30sec 2024