You can read this page with images and formula here: WASP_AI_Course_Module2
This repo contains the code for project number 3 of the WASP_AI_Course_Module2 course assignment.
To execute the code you just need to run the following command:
python project_3.pyThe code will first generate the halfmoon datasets (Train and Validation), then will train the model with different ALPHA values and will save a gif with the evolution of the linear separator that the algorithm has learned.
In the folder images you will find the results of a previous execution of the code.
The format is training_alpha_{alpha}_{k}_3.gif (where k is the number of iterations of the entire dataset, alpha the learning rate, and the history of the weights is updated after 3 gradient descent, hence a single frame contains 3 gradient descent steps).
We will start calculating the gradient of
This has been used to calculate the gradient of the cost function and hence perform the gradient descent. This can be seen in the code in the gradient_descent function of the project_3.py file.
We have then test the algorithm varing 2 different values:
- ALPHA, with the following values: [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10]
- And number of iterations over the entire dataset, with the following values: [1,2,3]
Varing
Decision Boundary for 
Decision Boundary for 
Decision Boundary for 
In the first case (
Considering instead the number of iteration of training over the entire dataset, as expected we can see that with the smaller alphas, it can require multiple iterations to reach a minimum. This instead becames neglegible compared to the larger
Over the same
Three iteration over the entire dataset for
Decision Boundary for 
Decision Boundary for 
Decision Boundary for 
We can see how the decision boundary become more and more accurate as we increase the number of iterations.
In conclusion, both the learning rate (