Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Perception learning algorithm implementation ( referring to week 4 ' s tutorial page 1 6 ) via Python ( Copy your python program to the

Perception learning algorithm implementation (referring to week 4's tutorial page 16) via Python (Copy
your python program to the answer sheet). Consider a perception in a two-dimensional case (d=2),
(a) Generate a linearly separable data set of size 20. Plot the examples (xn,yn) as well as the target
function f on a plane. Be sure to mark the examples from different classes differently and add labels to
the axes of the plot.
(b) Run the perceptron learning algorithm on the data set above. Report the number of updates that
the algorithm takes before converging. Plot the examples (xn,yn), the target function f, and the final
hypothesis g in the same figure. Comment on whether f is close to g.
(c) Repeat everything in (b) with another randomly generated data set of size 100. Compare your results
with (b).
(d) Repeat everything in (b) with another randomly generated data set of size 1,000. Compare your
results with (b).
(e) Modify the algorithm such that it takes xninR10 instead of R2. Randomly generate a linearly
separable data set of size 1,000 with xninR10 and feed the data set to the algorithm. How many
updates does the algorithm take to converge?
(f) Summarize your conclusions with respect to accuracy and running time as a function of N and d,
where N is the size of data set and d is the data dimension.
Hints:
One way to generate a linearly separable data set: first set your own target function, then keep
randomly generating data points and put each of them in the positive or negative class based on the
relation between the data point and the target function.
numpy.random.randint(low, size=(N,dim))): return random integers from the discrete uniform
distribution of the specified dtype in the half-open interval [0, low). The output shape is [N,dim].
numpy.random.choice(a, size=None, replace=True, p= None): generates a random sample from a
given 1-D array.
Some functions from Python package Matplotlib that may be useful: matplotlib.pyplot.xlabel, mat-
plotlib.pyplot.ylabel, matplotlib.pyplot.legend.
It is better to define some functions for perceptron experiments that can be reused in sub-questions.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions