Assignment 4


Due Date: Thursday, May 24 at 11:59pm


Late Policy: All assignments and projects are due at 11:59pm on the due date. Each assignment and project may be turned in up to 24 hours late for a 10% penalty and up to 48 hours late for a 30% penalty. No assignments or projects will be accepted more than 48 hours late. Students have four free late days they may use to turn in work late with no penalty: four 24-hour periods, no pro-rating. This late policy is enforced without exception.

Honor Code: Under the Honor Code at Stanford, you are expected to submit your own original work for assignments, projects, and exams. On many occasions when working on assignments or projects (but never exams!) it is useful to ask others -- the instructor, the TAs, or other students -- for hints, or to talk generally about aspects of the assignment. Such activity is both acceptable and encouraged, but you must indicate on all submitted work any assistance that you received. Any assistance received that is not given proper citation will be considered a violation of the Honor Code. In any event, you are responsible for understanding, writing up, and being able to explain all work that you submit. The course staff will pursue aggressively all suspected cases of Honor Code violations, and they will be handled through official University channels.


This assignment includes familiar datasets from past assignments. All of the data files are included in our assignment repo.

Setup Instructions:

We will be using Instabase as usual.

  1. You will need the files found at the following link copied to your personal Instabase account: Assignment 4. To copy files to your personal Instabase account, click on the drop-down menu above the folder listing, choose Select All, then click on the Copy link that appears. You should now have a private copy of the assignment to work on.
  2. Navigate to the repository where you copied the files to, and the folder should contain Assignment4.ipynb and three familiar csv files. Right-click or control-click on the notebook and select Open With > Jupyter. (If you simply double-click on it, it will show you the file but will not run Jupyter notebooks.) Sometimes it will take a minute or so for a new Jupyter server to start up on your behalf. Once it does, you are ready to go! In the notebook you will see clearly where you need to add code for the different steps of each problem.

Submission Instructions:

As we did for previous assignments, we ask that you submit both a PDF of the Notebooks through Gradescope and a copy of the Notebooks through Instabase link.

Submitting through Gradescope

  1. Download your Jupyter Notebook as a PDF, in print preview mode. With your Notebook pulled up in Instabase, press command-P for Mac, or ctrl-P for Windows, and save and submit a PDF version of the print preview. In Chrome, you can do this by changing the "Destination" as "Save as PDF" under "Local Destinations". Check that each of your answers is still there.
  2. Log into the Gradescope website ( using your Stanford email address. The TAs have already set up an account for you if you have not used Gradescope before.
  3. Click on the CS 102 class and click on Assignment 4.
  4. Upload your PDF and tag the pages corresponding to each question. You may submit as many times as you like before the submission deadline, and we will use your latest submission both for grading and for the late policy.

For more detailed instructions on submitting homework, take a look at the Gradescope FAQ.

Submitting through Instabase

Submitting through Instabase should be incredibly easy! At the bottom of the notebook, you will find a submission link and instructions. Please keep in mind that submissions are timestamped.

Part 1: Regression using Google Sheets

See Part1 of the notebook Assignment4.ipynb for questions and use it for answer submission as well.

Part 2: Naive Bayes on World Cup Data

For Part 2, please refer to the pdf file (A4Bayes.pdf) attached.
See Part2 of the notebook Assignment4.ipynb for questions and use it for answer submission as well.

Part 3: Using Python for Machine Learning

See Part3 of the notebook Assignment4.ipynb for questions and use it for answer submission as well.