Pre-class Assignment: The Perceptron Classifier (a simple neural network)#
Day 18#
CMSE 202#
✅ Put your name here
#Goals for today’s pre-class assignment#
What is the basis of a neural network?
Understand one type of early neural network, the “perceptron”
Assignment instructions#
This assignment is due by 11:59 p.m. the day before class and should be uploaded into the appropriate “Pre-class assignments” submission folder in the Desire2Learn website.
1. Neural Networks#
As we continue to peer into the world of machine learning, we’re going to spend some time in class working on building a simple ML classifier by hand. While understanding how to use pre-existing tools is an important skill, looking “under the hood” to understand a bit more about how some of these tools works can be extremely valuable as well!
When people talk about “deep learning” and “artificial intelligence”, it is often the case that they are talking (in one way or another) about neural networks. As the name implies, a neural network is a large network of simple processing elements, often referred to a “neurons”, as inspired by the neural architecture of the brain. Here is a little video to learn a bit about what a neural network is:
from IPython.display import YouTubeVideo
from datetime import timedelta
start=int(timedelta(hours=0, minutes=2, seconds=26).total_seconds())
YouTubeVideo("4qVRBYAdLAo", width=800, height=450, start = start)
✅ Question 1: Answer the following questions:
A. How do neurons communicate ?
B. How does a neuron compare to a perceptron ? That is, what similarities and/or difference do you see between a neuron and a perceptron ?
C. What was Dr. Frank Rosenblatt trying to classify ? What is Jabril trying to teach John Greene Bot?
D. What were the features Jabril was using to differentiate between donuts and bagels?
E. How many true-positives did John Green Bot get ? True-negatives? False-positives ? False-negatives?
✎ Record your answers below.
2. An introduction to the Perceptron model#
The following video will continue your introduction to the idea of the first kind of neural network ever developed, the Perceptron. It is important to pay attention to this video as we will be implementing a perceptron during our next in-class assignment, but don’t worry if you don’t understand absolutely everything discussed in the video quite yet. We’ll talk about the concept in class as well.
Watch the video and answer the questions.
from IPython.display import YouTubeVideo
YouTubeVideo("4Gac5I64LM4",width=800,height=450)
✅ Question 2: What important characteristic must data have in order for us to be using a Perceptron classifier?
✎ Do This - Erase the contents of this cell and replace it with your answer to the above question! (double-click on this text to edit this cell, and hit shift+enter to save the text)
✅ Question 3: How is this approach similar to the logistic regression classifier we used previously? How is it different?
✎ Do This - Erase the contents of this cell and replace it with your answer to the above question! (double-click on this text to edit this cell, and hit shift+enter to save the text)
✅ Question 4: What is the update rule used to improve the weights of the neurons?
✎ Do This - Erase the contents of this cell and replace it with your answer to the above question! (double-click on this text to edit this cell, and hit shift+enter to save the text)
✅ Question 5: What role does the “learning rate” play in the Perceptron model? How does changing the learning rate impact the behavior of the perceptron model works?
✎ Do This - Erase the contents of this cell and replace it with your answer to the above question! (double-click on this text to edit this cell, and hit shift+enter to save the text)
3. What to expect in class#
In class, you’re going to work with your group to see if you can code up a Perceptron classifier by hand. You’ll do this by building a new Python class, so if you haven’t thought about your Python-based object-oriented programming skills recently, you may want to remind yourself about some of the key elements that go into building a class. How do you define a class? How do you define class attributes? How do you define class methods?
If you could use a refresher on how to build Python classes, you may want to watch the following video.
from IPython.display import YouTubeVideo
YouTubeVideo("apACNr7DC_s",width=800,height=450)
Follow-up Questions#
Copy and paste the following questions into the appropriate box in the assignment survey include below and answer them there. (Note: You’ll have to fill out the assignment number and go to the “NEXT” section of the survey to paste in these questions.)
What important characteristic must data have in order for us to be using a Perceptron classifier? (you should be able to copy you answer to Question 2 from above)
How is the Perceptron classifier approach similar to the logistic regression classifier we used previously? How is it different? (you should be able to copy you answer to Question 3 from above)
Assignment wrap-up#
Please fill out the form that appears when you run the code below. You must completely fill this out in order to receive credit for the assignment!
from IPython.display import HTML
HTML(
"""
<iframe
src="https://cmse.msu.edu/cmse202-pc-survey"
width="800px"
height="600px"
frameborder="0"
marginheight="0"
marginwidth="0">
Loading...
</iframe>
"""
)
Congratulations, you’re done with your pre-class assignment!#
Now, you just need to submit this assignment by uploading it to the course Desire2Learn web page for today’s submission folder (Don’t forget to add your names in the first cell).
© Copyright 2023 Department of Computational Mathematics, Science and Engineering at Michigan State University