CMSC 373 Artificial Intelligence
Fall 2023


Assignment: The Perceptron (Due in class on Monday, October 30, 2023)

In this assignment, you will play with the Perceptron model to learn how to classify types of Iris flowers. Follow the instructions below. Be sure to read and then try each code snippet.
Make sure you have a Google account and are able to navigate to the Google Colab page: https://colab.research.google.com

Part 1: Explore the Iris Dataset (CMSCExploreIrisDataset)

Go to the link: https://colab.research.google.com/drive/1iKkgC-tXxjQkGUX-k6sBu6uQWmWex1EG?usp=sharing
First, create a copy in your own Drive by going to the File menu and selecting: Save a copy in drive.
In the tab for the copy, select the Filename and rename it with your own initials. For example, for a person with name X Warrior Princess, you can use the name: XWPExploreIrisDataset
Do this by clicking on the file name displayed at the top left.
Work through the entire workbook. Try some examples of your own (this is why you saved a copy above).

Part 2: The Perceptron Model.

Go to the link: https://colab.research.google.com/drive/1dUj8jqv78n3QsvH5BoGIlIVSrl0Y3enz?usp=sharing
First, create a copy in your own Drive by going to the File menu and selecting: Save a copy in drive.
Work through the entire workbook. Try some examples of your own (this is why you saved a copy above).
Once done, try the following at the end:

  1. Create a Perceptron model with 2 inputs and epoch limit of 1.
    Train the model.
    Test the accuracy of the model.

    How many inputs were incorrectly predicted?

Part 3: The Perceptron in Scikit-Learn

Go to the link: https://colab.research.google.com/drive/1drMaDR-yMGdL4dwbEUxehW_r-TpCkA9G?usp=sharing
First, create a copy in your own Drive by going to the File menu and selecting: Save a copy in drive.
Work through the entire workbook. Try some examples of your own (this is why you saved a copy above).
Next, let us try our inputs so that all four inputs (sepal Length, Sepal Width, Petal Length, and Petal Width)  are used to train the Perceptron.
In your Colab notebook, modify the Step [1] so that x[] contains all four inputs (i.e. no slicing):
x, y = dataset['data'], dataset['target']

Create and fit the model as before. Did the Perceptron learn?
As you can see, ML toolkits make it very easy for us to create, train, and test our models.
What to Hand In
Hand in a report on your results and experiences with the three Parts above. Only the report is needed. Send a PDF of the report by e-mail.

Back to CMSC 373 Page.