Dr Joshua Ho – a computer scientist at the Victor Chang Cardiac Research Institute – gives a step-by-step guide to a classroom activity to illustrate the concept of machine learning.
Based on my experience, the key to demystifying artificial intelligence (AI) is to emphasise that in almost all real-world situations AI is nothing more than imitation of human-like behaviours. The process of trial-and-error is at the heart of human learning and machine learning.
The number guessing game
I have been working with Matthew Scadding from the Ravenswood School for Girls in Sydney. We used a Lego Mindstorms EV3 kit, but the concept should be general enough so that this activity can be carried out using different programming languages.
We asked Year 6 students to build a computer program so that their robot could play a number guessing game. The game is as follows: the (human) player comes up with a whole number between 1 and 100 in their mind. The robot will repeatedly make a guess, say 26; after every guess, the human player provides feedback to the robot saying whether its guess was correct (=26), too small (>26) or too large (<26). The robot aims to guess the correct number in the smallest number of guesses.
Before the activity: I asked the class to brainstorm some strategies to make the robot guess the correct number as fast as possible, then compare these three strategies.
- Randomly pick a number between 1 and 100 every time, regardless of the previous attempts and human feedback;
- Systematically guess 1, 2, 3, … until the correct answer is reached;
- At the end of the iteration, use the human feedback to restrict the next range of values. For example, if the first guess is 80 and the human feedback indicates this guess was too large, the robot will only select from 1 and 79 in the next round.
Key concept: Most students could see the third strategy was the best because every new guess uses the feedback from the previous rounds to narrow down the solution search space. The first two strategies do not use human feedback in any meaningful way, so are very inefficient. The third strategy is said to be able to learn from previous mistakes and progressively adjust its guesses. This is the essence of learning by trial-and-error.
A prerequisite of this activity is that students need to have basic computer coding skills, including the knowledge of variables, loops, if-else statements, reading input from a sensor or keyboard, and printing text on screen. I have converted my code into computer pseudocode so it can be easily used for teachers who teach computer coding in different languages.
[Computer pseudocode for the number guessing game. Variable names are highlighted in red.]
At the end of the activity, I explained they had just built a simple machine learning program!
This is an edited version of an article that first appeared in Teacher magazine and has been reproduced with the permission of the Australian Council for Educational Research. To read the full article and to read more articles like this visit www.teachermagazine.com.au.