Search for question
Question

2. Code a 2-class perceptron learning algorithm using batch gradient descent (GD), for datasets that have 2 features (D = 2) You are required to code this yourself (e.g., sk-learn functions are not allowed). For the halting condition, have it stop when either of these conditions is met: (hl) All training data points are correctly classified (h2) 1000 iterations have been reached Also use the following values: Initialize the weight vector as w(0) = [111]" Learning rate n(i) = 1 Vi Terminology: for batch GD, 1 iteration is the same as 1 epoch. Code outline has been provided in the file HW3_perceptron.py. It includes code for drawing the plots; you will need to write functions for perceptron learning and testing as described in the code file. (a)-(c) Run your perceptron algorithm on the following datasets, using the train set for learning: (a) dataset1 (train and test) of HWI (b) dataset2 (train and test) of HWI (c) dataset3 (train and test) of HWI p. 1 of 3 For each dataset, output and report the following information: (1) Classification accuracy on the train set and test set; (ii) Which halting condition was met (iii) How many iterations were performed (iv) The weight values after halting (v) A plot of the criterion function /(w) on the train set after each iteration vs. iteration number (vi) A plot of the error rate on the train set after each iteration vs. iteration number ((v) and (vi) can be combined onto one plot) (vii) Two feature-space scatter plots that show the decision boundary and regions: one plot that also shows the training data points, and one plot that also shows the test data points (2 plots total for (vii)). (d) Comment on the performance of perceptron on the 3 datasets (that is, compare across the 3 datasets and explain similarities and differences). (e)-(g) Repeat parts (a)-(e) except use learning rate parameter n(i) = 10 vi. (h) Comment on similarities and differences of the results for n(i) = 1 Vi and n(i) = 10 Vi, for each test dataset.

Fig: 1