Home Page > > Details

ECS 170: Spring 2022

Homework Assignment 5

Due Date:

No later than Thursday, June 2, 9:15pm PDT. (You don't have to wait that long, and you

shouldn't. You have a final exam the next day. But I understand that some of you prefer to wait

until the last minute.)

You are expected to do this assignment on your own, not with another person.

This assignment looks really long. Don't panic. Most of this document is just examples.

The assignment:

Recall the perceptron learning model described in Lectures 16 and 17. Your task is to use Python

to write a function that implements the perceptron described in those lectures. Your function

should be named perceptron.

Your function should expect five arguments, in this order, left-to-right:

A number representing the threshold

A number representing the adjustment factor

A list of numbers representing the initial weights on the inputs

A list of examples for training the perceptron

A number representing the number of passes the perceptron should make through

the list of examples

Let’s map these descriptions onto the actual values used in the example:

In the example, the threshold was 0.5

The adjustment factor was 0.1

If contained in a list, the initial weights were [-0.5, 0, 0.5, 0, -0.5]

The list of examples was: [[True, [1,1,1,1,0]],

[False, [1,1,1,1,1]],

[False, [0,0,0,0,0]],

[False, [0,0,1,1,0]],

[False, [1,0,1,0,1]],

[False, [1,0,1,0,0]],

[False, [0,1,0,1,1]],

[False, [0,1,0,1,0]],

[False, [0,0,1,0,0]],

[False, [0,0,0,1,0]]]

The number of passes through the list of examples was 4

Each example in the list of examples has two parts. The first part (True or False) indicates

whether this example is a positive example (True) of the concept to be learned or a negative

example (False). The second part is a list of 1’s or 0’s. This list (the 1's and 0's) must be the same

length as the list of initial weights.

Now let’s say that the variable weights is bound to the list of weights shown above, and that the

variable examples is bound to that list of examples above. If you write your function exactly like

I did, then when your function is called like this:

>>> perceptron(0.5, 0.1, weights, examples, 4)

your function would print the following output (sorry, it’s really long, just like in Lecture 17):

Starting weights: [-0.5, 0, 0.5, 0, -0.5]

Threshold: 0.5 Adjustment: 0.1

Pass 1

inputs: [1, 1, 1, 1, 0]

prediction: False answer: True

adjusted weights: [-0.4, 0.1, 0.6, 0.1, -0.5]

inputs: [1, 1, 1, 1, 1]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.6, 0.1, -0.5]

inputs: [0, 0, 0, 0, 0]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.6, 0.1, -0.5]

inputs: [0, 0, 1, 1, 0]

prediction: True answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

inputs: [1, 0, 1, 0, 1]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

inputs: [1, 0, 1, 0, 0]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

inputs: [0, 1, 0, 1, 1]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

inputs: [0, 1, 0, 1, 0]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

inputs: [0, 0, 1, 0, 0]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

inputs: [0, 0, 0, 1, 0]

prediction: False answer: False

adjusted weights: [-0.4, 0.1, 0.5, 0.0, -0.5]

Contact Us(Ghostwriter Service)

- QQ：99515681
- WeChat：codinghelp
- Email：99515681@qq.com
- Work Time：8:00-23:00

- Fit5217help With ,Python Programminghe... 2022-05-31
- Help With Ecs 170,Help With C++/Python... 2022-05-31
- Help With Ecs 170,Help With Python/C++... 2022-05-31
- Fit 5003Help With ,Help With Java/C++ ... 2022-05-30
- Help With Cse 101,Help With C/C++ Prog... 2022-05-30
- Help With Econ7150,Help With Java，Pyt... 2022-05-30
- Econ7150 Programminghelp With S1 202... 2022-05-29
- Cse 101 Programming Help With Data S... 2022-05-29
- Help With Fit 5003 Software Security 2022-05-29
- Stat7055 Introductory Statistics For B... 2022-05-28
- Assignment 3 Description: Computer Sy... 2022-05-28
- C++ Programminghelp With ,Help With Pr... 2022-05-28
- Help With Eece 1080C,C++ Programminghe... 2022-05-28
- Comp10002help With ,Help With C/C++ Pr... 2022-05-28
- Swen30006help With ,Help With Java/C++... 2022-05-28
- Comp326 Coursehelp With ,Help With Pyt... 2022-05-28
- C++ Programminghelp With ,Help With Da... 2022-05-27
- Help With Mast30025,R Programminghelp ... 2022-05-27
- Prog2002help With ,Help With Sql Progr... 2022-05-26
- Info411/911Help With ,Help With Java/P... 2022-05-26

Contact Us - Email：99515681@qq.com WeChat：codinghelp

© 2021 www.asgnhelp.com

Programming Assignment Help！