Introduction
There are many ways to build machine learning programs. In this lesson, students explore two of the basic types of machine learning: unsupervised learning and supervised learning.
Learning Goals
- Engage in hands-on activities to train a machine in two ways
- Understand the difference between supervised and unsupervised learning
- Understand real-world applications of machine learning
Vocabulary
- Supervised Learning
- A type of machine learning task. If we know what we want the computer to be able to identify, or the categories we want it to distinguish among, this is the type of machine learning we use. The initial data is labelled so the machine can learn which features are shared by data in certain categories. It then generates an algorithm to categorize future, unlabelled data. Humans can check the accuracy of these predictions and get feedback to improve the algorithm. Right now, this is the most common type of machine learning.
- Unsupervised learning
- Another type of machine learning task. This approach is ideal for identifying general similarities and useful patterns—even the kind that humans don’t tend to notice. Humans do not guide machines to group information, and patterns emerge on their own.
Guiding Questions
- Can computers learn? How do they learn? (Answer: Yes, today we’ll look at how to teach computers.)
- Can a computer tell the difference between objects? How do they know how to do this? (Answer: Yes, but we need to teach it using examples, or create algorithms to identify patterns to recognise objects.)
- Why do computers need people to help them learn? (Answer: We teach computers to identify patterns and recognize objects.)
Curriculum Links
This module aligns with provincial and territorial Computer Science curricula, providing an opportunity for students to explore emerging areas of computer science research. In addition, through the Social Studies curriculum, students have the opportunity to assess the significance of an event (in this case, AI) on people, places and developments at this time in history.
Materials
- A device (computer / tablet / smartphone) with internet connection and a camera
Computer Activity
Activity 1: Recog (5 minutes)
In this activity, students work as a class on making a machine learning project that teaches a device to identify their handwriting. They will use Google Teachable Machine for the project. The video below shows an example of how this tool can be used.
Recog is an open-source educational program that can learn to recognize individual handwritten characters. It uses a two-layer neural network to learn new characters and refine its knowledge of those it already knows. Students can hand-train Recog in two ways—supervised or unsupervised—to recognize digits, vowels, arrows in different directions and symbols of their own making. It takes about three examples of each figure for the program to recognize a set of around 10 patterns. Use the following web app Recog.
Students use a pre-trained neural network to see how well it can recognize their handwriting.
- Draw a letter, number or symbol with the mouse.
- Press Digitize to see how the software makes sense of what has been drawn and turns it into a series of squares.
- Select the model 0123456789 from the drop-down menu. This is a neural network that has already been trained to recognize digits from 0 through 9.
- Press Recognize to have Recog compare the new symbol with the models it has stored and return the probability that that the new symbol is a match for each of the elements in the program’s memory.
- If it identifies the symbol incorrectly, click Learn and tell it the correct answer.
- Repeat three times for each number. How well did it do?
- Try entering a completely different symbol. What does the neural network do?
Activity 2: Supervised Learning—How’s Your Handwriting? (25 minutes)
Each student trains their model with their own handwriting. They then experiment with their handwriting on their neighbour’s system and see that it performs more poorly at first, due to differences in letter formation, then watch it learn.
- Select New from the Network dropdown and Supervised from the Learning dropdown.
- Press Add to add a new character for the neural network to learn. Repeat for all the characters you would like the neural network to learn.
- Draw a letter, number or symbol with the mouse.
- Press Digitize to see how the software makes sense of what has been drawn and turns it into a series of squares.
- Select the correct symbol and press Learn.
- Repeat all chosen symbols three times, then test your partner’s computer.
Activity 3: Unsupervised Learning—Break the Code (25 minutes)
Teams of two face off. Which team can train their AI and break the code the fastest?
Each team is given a secret five-letter word.
- One person on each team of two sets the program to unsupervised and submits all their symbols again. This time, the program will group them into types and create numbered categories.
- Continue to train the machine to label the first letter of the secret word as “Type 1,” the second as “Type 2,” and so on. Train it as much as you want, but remember, you’re being timed!
- When you think the program has had sufficient training, it’s your partner’s turn to decode your words. The team to decode all their partner’s words first is the winner.
Optional language integration: Train the learning program on other languages such as Inuktitut or French!
Conclusion
Class Discussion (10 minutes)
There are many applications that need to recognize characters—in fact, this ability was one of the very first use cases of machine learning. For example, this is essentially the type of algorithm Canada Post uses to scan and recognize addresses on envelopes. It’s also similar in concept to what Google uses to identify copyrighted music, or the way self-driving cars are trained to recognize stop signs. The current systems are just much more sophisticated.
- When Canada Post developed its system to scan handwritten as well as typed addresses on envelopes, what do you think the challenges might have been?
- In the Recog game, you drew each character in a box. What advantages do you think the box might give a character-recognition algorithm?
- Can you think of ways a system like this might be used to improve peoples’ lives or make some tasks easier?
- Do you think the system would be more effective in reading cursive or printed handwriting? Do you think fonts impact the ease of recognition?
- Are there ways we might not want this type of machine learning to be used?
Resources
Additional Resources
- Briana Brownell’s newly-released five-minute animated TED-Ed video “What Is Machine Learning?” explains the styles of machine learning
Social Media Resources
- Briana Brownell Twitter