0% found this document useful (0 votes)
109 views5 pages

Deep Learning Practical Assignment #1:: Instructions

The document provides instructions for a practical assignment to implement the perceptron algorithm from scratch to classify and predict data. Students must complete the assignment in groups of up to 3 people by submitting a Jupyter notebook containing implementations of the perceptron algorithm, answers to theoretical questions, and results from experiments with different datasets. The assignment aims to understand the time and space complexity of the perceptron algorithm and study how varying the variance of datasets impacts the algorithm's performance.

Uploaded by

Gaith Belkacem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views5 pages

Deep Learning Practical Assignment #1:: Instructions

The document provides instructions for a practical assignment to implement the perceptron algorithm from scratch to classify and predict data. Students must complete the assignment in groups of up to 3 people by submitting a Jupyter notebook containing implementations of the perceptron algorithm, answers to theoretical questions, and results from experiments with different datasets. The assignment aims to understand the time and space complexity of the perceptron algorithm and study how varying the variance of datasets impacts the algorithm's performance.

Uploaded by

Gaith Belkacem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Deep learning Practical Assignment #1:

Linear Classifier : Perceptron

Lab date : October 10th, 2021


Deadline to submit : October 25th, 2021 - 11:59 PM (23:59)

Instructions
Read all the instructions below carefully before you start working on the assignment.

• You must do this assignment in groups of at most 3 students.

• You must implement all algorithms from scratch.

• Please submit a jupyter notebook that contains:

– A section (multiple cells) for your answer to the theoretical questions.


– A section (multiple cells) for the installation of the used packaged. please specify
the exact package version to avoid possible conflicts.
– A section (multiple cells) for you implementation.

• Please submit your notebook to your corresponding git branch in our git work-space.

• Late submissions will be graded as follows:

– On time submission grade SG.


2
– SG = 0.95 ∗ SG for each day. Capped at 3
∗ SG

• Early submissions will be graded as follows:

– On time submission grade SG.


5
– SG = 1.02 ∗ SG for each day. Capped at 4
∗ SG

• Code that does not work will be graded accordingly. Please focus on the algorithms
you are implementing.

Practical assignment objective


• To implement the perceptron algorithm from scratch in order to classify then predict
data.

1
1 Working with perceptron algorithm
We can implement the perceptron algorithm in different ways. One of these implementation
is the followings:

Implementation of Perceptron algorithm


input: A training set S = {(x1 , y1 ), . . . , (xm , ym )|xi ∈ Rd }
initialize: w(0) ← (0, . . . , 0)
for t = 1,2,. . . , some upper bound n do
for (xi , yi ) ∈ S do
if yi hw(t) , xi i ≤ 0 then
w(t+1) ← w(t) + yi xi
end if
end for
if w(t+1) = w(t) then
return w(t)
end if
end for
In this assignment please implement this version of perceptron algorithm.

Question 1
In this section, we aim to understand the space complexity and time complexity of the simple
perceptron algorithm.

Question 1.a
What is the computational/time complexity of the basic perceptron algorithm.
Please define the complexity as function of the variables defined in the provided algorithm

Question 1.b
What is the space complexity of the basic perceptron algorithm.
Please define the complexity as function of the variables defined in the provided algorithm

2 To understand you need to implement !!


In this segment we implement the perceptron algorithm.

Implement from scratch only the perceptron algorithm, for data splitting and suffling and
other operations, you can use 3rd party libraries

2
2.1 Toy data set
Consider a data set S = {(xi , yi )}250
i=1 consisting of 250 points xi = (x1 , x2 ) and their labels
yi .

• The first 125 xi have label yi = −1 and are generated according to a Gaussian distri-
bution xi ∼ N (µ1 , σ12 I) , where
 
−1
µ1 =
0

• The last 125 xi have label yi = 1 and are generated according to a Gaussian distribution
xi ∼ N (µ2 , σ22 I) , where
 
1
µ2 =
0

After shuffling the data-set, split it into train and test set, containing 80% and 20% of the
dataset.

2.2 Experiments
Implement the perceptron algorithm

Experiment 1
Generate one data set for σ12 = σ22 = 0.25.

• Question 1: Does the algorithm converges? Why?

• Question 2: Plot the decision boundary found by your algorithm. Is this decision
boundary unique? Does changing the initialisation changes the result of the algorithm?

• Question 3: Compute the accuracy of the classification on the test set. Plot the
decision boundary on the test set.

Experiment 2
Generate one data set for σ12 = σ22 = 0.75.

• Question 1: Does the algorithm converges? Why?

• Question 2: Plot the decision boundary found by your algorithm. Is this decision
boundary unique? Does changing the initialisation changes the result of the algorithm?

• Question 3: Compute the accuracy of the classification on the test set. Plot the
decision boundary on the test set.

3
Comment the results found in the previous two experiments.
The result should be similar to the figure below, varying the variance will impact the result

Experiment 3
We define one experiment as following

• Generate the data and train your model .

• Compute the error on the test set.

In order to study the impact of varying σ12 and σ22 on the performance of the system, we
store the error over multiple experiments (take nb experiment = 30). Then we compute the
mean and the variance of the stored errors.

for each σ12 and σ22 ∈ [0.01, 0.1, 0.5, 0.7] compute the mean and variance then plot the results
using matplotlib.pyplot.errorbar .

The following figure should be similar to the expected result

4
Comment the result.

You might also like