$29
Implement general perceptron learning algorithm
This assignment involves implementing Perceptron algorithm in Python and testing it on various datasets. The training and test data sets will be uploaded in Moodle. Study how to use Jupyter notebook, scikit, numpy, scipy and matplotlib. Write a general python code that works for every dataset rather than di erent codes. Submit the executed code in Jupyter notebook. You can write your observations and results using the heading and markdown cells in Jupyter.
1. Implement Perceptron algorithm in Python from scratch on the datasets uploaded in Moodle.
(a) Find the decision boundary using Perceptron algorithm on training data and plot it as shown in Figure 1.
Figure 1: Classi cation
(b) Classify test data and plot the classi cation results.
(c) Plot the loss vs iteration curve, classi cation error vs iteration curve, classi cation accuracy vs iteration curve for training data and report your observations.
(d) Find the classi cation accuracy, the number of true positives, true negatives, false positives and false negatives for both training and test data.
(e) Observe the weights obtained and the features of the dataset and report your ndings.
2. Employing the code on real data:
1
(a) Use the code written above to classify a real data set. Split the dataset into training and test data sets in the ratio 80:20 respectively. There are four input variables and 1 output variable in the dataset. The dataset is in the form of a csv le. The last column contains the output variable. The two classes are denoted by 0 and 1. Train the perceptron model on training data and use the model to classify test data. You need not plot the datasets as it is not two-dimensional. Perform all the tasks listed in Question 1 from 1(c) to 1(e).
(b) Normalize the data by rescaling the input values so that they always lie between 0 and 1. Perform all the tasks mentioned in question 2(a). Compare the results for both the normalized and un-normalized data and report your observations.
2