Jaya
Computer Science

Modules and Ideas for Computer Science Courses

By Jaya Nilakantan
Cohort 2019-2020

AI Portfolio

Here are some of the modules that I developed this past year to introduce Computer Science Technology students to machine learning concepts. Along the way, I noticed that some basic concepts are easy to grasp, while others are trickier and require a more substantial background in Mathematics. Here are some on the lab exercises and more substantial projects, as well as background material used to present these ideas to students. Feel free to reuse!

 

Genetic algorithms / reinforcement learning

Winter 2020, with Swetha Rajagopal

Audience: 4th Term Comp Sci Technology

Overview

This activity is based on Robby the Robot described in Chapter 9 of Melanie Mitchell’s book , and heavily influenced by a project given by my wonderful Physics colleagues Jon Sumner, Sameer Bhatnagar and Jean-Francois Briere. Their version is found . Robby’s task is to collect empty soda cans that lie scattered around his square grid world, by following instructions encoded in an array of 243 genomes.

robby

Material

Prior to commencing the activity, we went over the presentation below, and saw the demo (a longer version of the gif with the best algorithm of certain generations). It was very motivating for students to see Robby improve from basically doing nothing in the first few generation (or even worse, repeatedly getting negative points from walking into a wall) to getting a near perfect score by the 1000th generation. A student asked if this algorithm proves eugenics ?

Presentation: GA

Instructions: RobbyTheRobot

Notes

  • Visualizing Robby’s improvement is an important part of this project and greatly improves motivation. We used Monogame, but at the time of writing it appears to no longer be actively supported.
  • You can provide as much or as little code as you see fit, based on the amount of time the students have allocated.
  • Unit-testing an application that uses a pseudo-random number generator is challenging: students need to understand the seed, and use it appropriately.

 

 

Classification algorithm – K-Nearest Neighbours

Winter 2020, with Swetha Rajagopal

Audience: 4th Term Comp Sci Technology

Overview

This activity was used in the very first week of class, to remove any programming cobwebs after the winter break! Students were introduced to basics of classification and the KNN algorithm though a whiteboard discussion. The rest of the period was spent on implementing the KNN algorithm.

Material

Background and instructions: KNN

Notes

  • Some algorithms lend themselves well to short-ish exercises that can be tackled in a lab period or two. KNN is one of these algorithms, as are basic regression and Naïve Bayes. The mathematical prerequisite is not much more than high school level.
  • you can provide as much or as little code as you see fit, based on the amount of time the students have allocated

 

 

Text generation with a character-level model

Fall 2019, with Josiane Gamgo

Audience: 5th Term Comp Sci Technology

Overview

At the time this activity was undertaken, OpenAI had just decided that the full GPT-2 transformer language model was to release to the public (a decision that was reversed a mere … ).  This opened a discussion about the probabilistic nature of most machine learning algorithms, and lay the groundwork to introduce generating text “in the style of” Shakespeare.

shakespeare3.gif – credit Davide Catalano and Kevin Armstrong Rwigamba

Gif credit: Davide Catalano and Kevin Armstrong Rwigamba

Material

We watched the excellent and highly recommended short film “Sunspring”. Although it is getting dated from a tech perspective, the acting is wonderful, and the opening crawl showing all the texts used to train the neural network was a natural segue to the training that we would have to do on our Shakespeare text generator.

Video:

Source:

 

Instructions: TextGenerator

Notes

  • This project had a clear training phase followed by a generation phase. The training phase was long: we had a 4.5 MB corpus of all Shakespeare’s texts and we were using PHP, not a particularly fast language. We persisted our training data in a Redis store (an SQL database was far too slow) and used AWS Educate to have an environment with enough memory and horsepower.
  • Visualization with a JavaScript-powered web application is a feature requirement that can be added as it makes the end result much more enticing (the gif is taken from 2 students’ work)

 

 

Collection of beginner AI and ML material

If you teach in computer science, you have probably turned to Stanford’s – . a collection of interesting and nifty assignments for CS0 to CS2 students for inspiration. They are not necessarily AI related, but Dan Pomerantz and I used a assignment as a basis for a web-based bookstore a few years ago.

The site “seeks to gather and disseminate the best assignment designs of the Artificial Intelligence (AI) Education community”. The level of these assignments is higher than Nifty’s, but you may find inspiration (note that you will find a variant).

I thought it would be nice to build a repository of AI-related assignments and modules that work at the CS0-CS2 level which is where our student fit. My feeble attempt is in the repository. I will get back to populating this repository soon!