0% found this document useful (0 votes)
52 views

Assignment-2: Abhishek Shringi

The document summarizes the application of the perceptron algorithm and logistic regression on a dataset to classify students' exam results. It includes: 1) Applying the perceptron algorithm to train the dataset, calculating an accuracy of 81%. 2) Making predictions on test data and plotting the decision boundary. 3) Comparing perceptron to logistic regression, finding logistic regression converges slower but with higher accuracy and a better decision boundary.

Uploaded by

Franklin Garyson
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Assignment-2: Abhishek Shringi

The document summarizes the application of the perceptron algorithm and logistic regression on a dataset to classify students' exam results. It includes: 1) Applying the perceptron algorithm to train the dataset, calculating an accuracy of 81%. 2) Making predictions on test data and plotting the decision boundary. 3) Comparing perceptron to logistic regression, finding logistic regression converges slower but with higher accuracy and a better decision boundary.

Uploaded by

Franklin Garyson
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Assignment-2

Abhishek Shringi

19-03-2021

CLL788|Process Data Analytics

Prof. Hariprasad Kodamana
Ans 1) (a) We applied the perceptron algorithm in order to train the dataset “q1train”, after doing
appropriate manipulations and converting it to required matrix.

The following steps were done to implement perceptron algorithm:

1) Initialization of parameters to 1.
2) Learning rate(𝛼) is assigned.
3) Then , stochastic gradient descent was used, in which the following update rule for the
parameters was used.
𝜃 ≔ 𝜃 + 𝛼. 𝑥𝑛 . 𝑡𝑛

where ;

i) xn denotes the misclassified examples i.e. the points which satisfy 𝜃 𝑇 . 𝑥𝑛 . 𝑡𝑛 < 0
ii) tn =1 if label =1( given in dataset)
=-1 if label =0 (given in dataset)

Observation and Analysis:

1) A lot of combinations of learning rates and iteration were tried , it was observed that a good
accuracy was occurring at \alpha= .0004 and iterations=1000 over all training examples.
A graph of error v/s iteration was plotted for the above value of learning rate to show
convergence:

2) Predictions were made on the given dataset , in order to calculate the accuracy of the
perceptron algorithm on the given training data, which was calculated as :
Accuracy = (TP+TN)/(TP+TN+FP+FN)
TP: True positive | FP: False positive

Assignment-2 PAGE 2
TN: True negative | FN: False negative

The accuracy % turned out to be as high as 81 % which shows that almost 80% of the data in
training is getting correctly classified with a straight line decision boundary based on the perceptron
algorithm

3) A scatter plot of the true values , along with the decision boundary was plotted :

4)

It can be inferred from the above graph that perceptron classified the points which below the
decision boundary as the Fail ones and those which are above the decision boundary as Pass
ones, which is quite a fair classification as seen from the above graph and the high accuracy of
80% that we got.

B) Now the predictions were made for the the test data, similar to training data firstly it was scaled
and fed into the perceptron predictor, the result is shown in the following graph:

Assignment-2 PAGE 3
The points above the decision boundary shows Pass ones while those below shows Fail ones.

C) Comparison between logistic regression and Perceptron Algorithm:

• Error V/s iteration graph for both logistic and perceptron was plotted for α=.0004 :

Perceptron Algorithm Logistic Regression

It can be inferred from the above case that for a learning rate , perceptron converges much faster than logistic
regression atleast in this case as perceptron shows good convergence at around 1000 iterations , while for logistic
regression it takes around 7000 iterations.

Assignment-2 PAGE 4
• Decision boundaries of logistic regression and perceptron were plotted in a scatter plot of features:

From the above two plots, it can be inferred that logistic regression gives better performance in comparison
to perceptron , showing higher bias. This fact was further verified by calculating the accuracy of the logistic
regression which came out to be 82.8% while for Perceptron it came out to be 81%.
• Finally graph for test data was plotted for comparison:

We observe that logistic regression classifies the data more uniformly in both classes in comparison to
perceptron which is slightly biased (qualitatively) for the Pass category.

Assignment-2 PAGE 5
Ans2)

Assignment-2 PAGE 6
Assignment-2 PAGE 7
Assignment-2 PAGE 8

You might also like