The Royal Society has recently recommended that, given its importance to society, Machine Learning needs to be incorporated in to the school curriculum. Here we will explore some simple ways to introduce Machine Learning in to existing teaching across all key stages.
Machine Learning Technology is already a part of all of our lives. It is making decisions both for us and about us. It is the technology behind:
- Facial recognition
- Targeted advertising
- Voice recognition
- SPAM filters
- Machine translation
- Detecting credit card fraud
- Virtual Personal Assistants
- Self-driving cars
- … and lots more.
To fully understand the opportunities and consequences of the machine learning filled future, everyone needs to be able to …
- Understand the basics of how machine learning works.
- Develop applications by training machine learning engine.
- Use machine learning applications.
- Understand the Ethical and Societal Issues.
This education needs to start in school from primary onwards. There are many ways it can be embedded in the curriculum, both while supporting other subjects and explicitly learning about machine learning.
Here we give an overview. We provide some ideas, activities and resources for use in lessons to go deeper. Many are contained in our free booklet “Artificial Intelligence: but where is the intelligence?”.
- What is Machine Learning?
- Understanding How Machine Learning Works
- Using and Developing Machine Learning Applications
- Understanding the Ethical and Societal Issues
- Teaching Machine Learning across the curriculum
- More Resources
What is Machine Learning?
Machine Learning is a technology that “allows computers to perform specific tasks intelligently, by learning from examples”. Rather than crafting an algorithm to do a job step by step…you craft an algorithm that learns to do things itself then train it on large amounts of data. It is all about spotting patterns in massive amounts of data.
In practice creating machine learning tools is done in several steps.
- First create a machine learning engine. It is a program implementing an algorithm of how to learn in general. (This step is for experts!)
- Next you train it on relevant data (e.g. images of animals). The more data it sees the better it gets at recognising things or making decisions (e.g. identifying animals).
- You package up the newly trained tool in a user interface to make it easy for anyone to use it.
- Your users then use the new machine learning application by giving it new data (e.g. you show it pictures of animals and it tells you what kind of animal they are).
Here is an example of a robot with a machine learning brain. It reacts just to the tone of voice – it doesn’t understand the words. It learnt very much like a dog does. It was ‘rewarded’ when it reacted in an appropriate way and was ‘punished’ when it reacted in an inappropriate way. Eventually it learnt to behave like this.
What do we mean by spotting patterns? One way to think about it is that it is just grouping the data based on which is most similar. So in the case of our robot that has learnt to show a given expression when it hears a given sound it is grouping the data (sounds combined with the positions of its eyes, mouth and eyebrows) as illustrated in the diagram. Each time it hears a sound and places its eyes, mouth and eyebrows in a particular position, it gets feedback on whether that was appropriate or not. Over time it learns the pattern of which combinations are acceptable.
Ultimately it learns to show expressions that are very human like.
Suppose the idea was to train a tool as a classifier to be able to tell what something is – is a sound sad, happy or surprising? Then, once it has learnt the patterns, when some new data arrives (represented by the red dot), a new sound say combined with the expression on listeners faces, it just makes a choice based on which cluster that data point most clearly corresponds to. The red dot must correspond to a sad sound.
Understanding how machine learning works
There are several ways to try to make a machine do tasks ‘intelligently’. For example:
- Rule-based systems (writing rules explicitly)
- Neural networks (copying the way our brains learn)
- Genetic algorithms (copying the way evolution improves species to fit their environment)
- Bayesian Networks (building in existing expert knowledge)
We will explore each in turn, before looking at social and ethical issues of machine learning.
Intelligence & rules: the intelligent piece of paper
The first step in understanding Machine Learning is to understand how computers might be able to do things ‘intelligently’ without learning. This can be illustrated with our ‘Intelligent Piece of Paper’. We claim our intelligent piece of paper is more intelligent than most humans! How could this be true? It is just a piece of paper.
Why do we claim it is intelligent? Because it is better than most humans at its favourite game: Noughts and Crosses. It has played hundreds of times and has never lost. Of course if both players play well then any game of Noughts and Crosses should be a draw. Our piece of paper has drawn about half the games it has played but won the rest. If you didn’t know you were playing a piece of paper you would think it is rather smart! (for example, if it stayed in another room and we just texted you its moves)
What did we do to the piece of paper to make it smart? We wrote on it some rules: rules to play the perfect game of noughts and crosses. Follow what it tells you blindly and you will play the game perfectly even if you’ve no idea what you are doing. Is it intelligent if it is just about following rules? That is all any computer does. If the paper isn’t intelligent because it is just following rules, then no computer could ever be as that is all they do.
Here are its rules for going first (you need the rules on its other side too if you are going to make it play second ever!):
I am X, and I go first. Move 1: Go in a corner. Move 2: IF the other player did not go there THEN go in the diagonally opposite corner to move 1. ELSE go in a free corner. Move 3: IF there are 2 Xs and a space in a line THEN go in that space. ELSE IF there are 2 Os and a space in a line THEN go in that space. ELSE go in a free corner. Move 4: IF there are 2 Xs and a space in a line THEN go in that space. ELSE IF there are 2 Os and a space in a line THEN go in that space. ELSE go in a free corner. Move 5: Go in the free space.
To write the rules – the algorithm – we had to work out a perfect strategy to win the game. We played lots of games in a structured way. We played a game and noted the result, then took back the last move and tried another again noting the result, and so on. We then took back two moves. Eventually we worked out which moves guaranteed we would not lose and turned them in to rules.
Arguably the intelligence is not in the rules but in coming up with them – in learning how to play. However, we can easily turn the above strategy we followed into an algorithm for working out how to play perfectly. Would those new rules be intelligent then? They came up with the way to win!
Perhaps intelligence itself is not the point, just being able to do specific tasks. It is being able to learn that matters whether that is intelligent or not. If we can create algorithms that can learn then we can create programs that can do all sorts of things well. That is where Machine Learning comes in…
Biology: Neural Networks and how the brain works
One of the main ways that machine learning is done is through what are called neural networks. Computer scientists try to make machines intelligent by copying some of the way our brain works. Explore how the nervous system, neurons and so our brains work by building a working brain that plays Snap out of rope, tubes and kids: a computational model of a brain. At the same time understand the basics of how neural networks work.
- The Brain-in-a-bag Activity: create a brain from kids rope and tubes that plays Snap!
- Build-a-brain coin snap: Paper and coin version of the above
Neurons are just simple computational units. Signals (actually neurotransmitters) arrive on inputs from connected neurons. When enough signal has arrived in, the neuron fires and sends signals out to all the neurons it is connected to. This is enough for neurons to act like logic gates. By setting the neurons to fire on different thresholds and connecting them in different ways you can make diferent things happen – such as creating a brain that plays Snap. Some neurons are connected to sensors to sense the world (the input layer in machine learning terms). Others are connected to muscles to have action in the world (the output layer). In between are the relay neurons that provide the logic.
As the sensors (in our case our senses, like our eyes) cause the sensory neurons to fire, the trigger a cascade of firing of connected neurons, that may or may not ultimately trigger muscles to do things (like shout “Snap!”). In machine learning this cascade of signals through the network is called ‘forward propagation‘. In itself that does not involve learning though. Let’s explore a simple form of machine learning algorithm…
A machine that learns: the sweet learning computer
Rather than trying to write rules – algorithms – for each task we want an intelligent machine to do, we actually write algorithms that say how to learn. Explore a simple algorithm for learning by building our Sweet Computer from sweets and cups. Then play it at the game of Hexapawn. Can you learn how to win the game faster than it does?
The way it works is that each board position is represented by a cup of sweets. There is one sweet for each possible move at each position. The sweets represent a ‘rule’ that any of those moves are possible. To decide where to go a sweet (so a move) is chosen at random from the cup of the current board position, and that move played. If a move immediately leads to losing the game, then the corresponding sweet is eaten. The computer will never make that move again (so not make that mistake). Over time more and more sweets are eaten. The only ones left eventually correspond to winning moves. They spell out rules saying what moves to make in each position.
If no sweets are left for a given position then the rule is “RESIGN!”. In that case the sweet from the previous move is eaten. In this way the learning effect propagates backwards through the moves and earlier and earlier moves lose sweets and so gain better and better rules.
A variation is to add sweets to all moves that led to a win, but remove the last sweet that led to a win. This makes winning moves more likely to be taken, but losing moves less likely.
To find out more go to the activity page:
How neurons learn
Neurons ‘learn’ by adjusting the thresholds that determine when they fire. Neural networks that are trained on labelled data work in the same way. When being trained, they make a prediction based on the current settings of when to fire the neurons. If the answer given doesn’t match the label which gives the correct answer then they adjust the thresholds that led to the wrong answer. This is similar to the way the Sweet Learning Computer (above) learns, but instead of adjusting how many sweets there are, it adjusts the threshold of when to fire a neuron.
Stopping SPAM with machine learning: weighted rules
Those of us who use email are bogged down in SPAM – unwanted email often with nefarious purposes. Let’s use it for a good purpose for once – to help us see how machine learning works. You could create lots of rules, initially random rules, each that try to predict whether an email is SPAM. Each gives a score about how likely the email is SPAM. Some are more successful than others. If they are then raise their score, but if they get things wrong lower the score. The more emails that are and aren’t SPAM the more accurate their weightings get. Some rules fade away whereas more successful ones get stronger and stronger…
Using / Developing Machine Learning Applications
The best way to properly understand the power of machine learning and the process of developing and training machine learning tools is to actively use existing tools and in particular train them and so see them learn.
There are a variety of opportunities to see machine learning tools in action more explicitly, introducing them in to the classroom. For example, Quick, Draw! uses a neural network that is learning to recognize doodling. You help teach it by adding your drawings to the world’s largest doodling data set. In doing so you can help with machine learning research.
Combine it with a drawing activity where pupils try to guess each other’s doodles, and then try and say exactly what features the doodle is made up of that allows it to be recognised.
Creating your own Machine Learning Tools
Machine Learning for Kids has created a machine learning engine plug in for Scratch. This makes it possible to write your own Machine Learning applications. It provides a series of lessons for developing specific applications in Scratch. You can train the underlying Machine Learning engine yourself on data, including images. This creates a series of specialist Machine Learning blocks you can use in Scratch. By adapting the ideas from the given code you can create your own ideas.
Understanding the Ethical and Societal Issues
Machine learning has great potential to do a great deal of good for humanity. There are very many opportunities such as in healthcare. There are also traps, however. If we let it it can also cause great harm. This is one of the reasons it is important everyone understands the technology.
These issues can be incorporated into PSHE, Computing and English lessons, for example.
PSHE: Stereotypes, prejudice and discrimination
Machine Learning apps reflect society even the bad bits! It is possible that they could enhance stereotypes, prejudice and discrimination. They are based on data, but if that data contains decisions made by past humans, then it could just reinforce that. For example if a machine learning tool was used to set pay levels of new employees, but its data was based on pay levels of workers historically, then it could identify the pattern that women are paid less than men, and so use that as its criteria.
- A “Racist” prison sentencing program
It is important that algorithms that make decisions about us can explain themselves. At the moment that is really hard for the machine learning programs out there. They just learn patterns, but what those patterns are, who knows…
Social networks are awash with chatbots that masquerade as humans. Could they swing elections, so undermining democracy? If they are prejudiced and spout racist nonsense, could this influence their followers to be more prejudiced.
- A “Racist, sexist” Chatbot
There is also a question of how information that results from classification algorithms is used. Programs exist for example to tell whether a woman is pregnant from her shopping habits. How might an employer use that information? Another program identifies gay people from a picture of their face. What might an oppressive regime do with such information?
- A programs identifies pregnant women from their shopping habits
- A program identifies gay people from their face
Understanding the privacy issues around personal information and big data matters.
- You are giving vast amount of (valuable) information about yourself away (for free).
- It can be used to deduce a lot more about you than you may think you have given away.
- It will be used to make decisions about you that affect your life (but there will be no argument of why).
Just because a machine says something about you doesn’t make it true! For example, the program that ‘identifies’ people who are gay has accuracy of around 90%. That sounds good but it means it gets 1 person wrong in every 10 it makes a judgement about. Is that acceptable?
Teaching Machine Learning across the curriculum
There are many different ways Machine Learning could be introduced in to the curriculum, because of the way it cuts across other subjects. This can in many cases just be by pointing out explicit links such as when teaching about the nervous system in biology.
Here we suggest some other ways to introduce Machine Learning in cross curricula topics.
English: Write a story inspired by machine learning
The societal, ethical and privacy issues behind Machine Learning and Big Data have potential for topics for writing fiction. For example, read the story “Robot” written for cs4fn at
First search for and read a selection of news stories about machine learning (or read some of the cs4fn articles e.g. above) for inspiration, then write your own short story inspired by the ethics of machine learning.
Music and Sound
Rebecca Fiebrink has use Machine Learning in a way that allows anyone to create their own musical instrument – out of thin air. She uses machine learning to enhance creativity of humans…Rather than learn some pre-existing relationship it gives a very quick way to code what would otherwise be very complex programs. You code by showing it examples of say hand positions and the sound they should make. It learns what you were thinking, but if you only have a vague idea it still comes up with something.
Another musical related application of machine learning is that of identifying birds. The thing about birds is they are very hard to see. You do hear them though. How might you write a program that can determine which birdsong you are hearing? One way is to get expert bird watchers to write rules about how they sound. Another is to give a machine learning program lots of example bird song that those experts have identified. They no longer have to work out how they know the difference: they just identify them and leave the machine learning tool to work out the pattern.
There are lots of resources being developed by different organisations and people suitable for novices to find out more about Machine Learning, and for use in school. Here are some:
The Royal Society has been investigating the potential of Machine Learning technology over the next 5-10 years, as well as the barriers to realising that potential. In addition to a detailed report they have proved a series of videos and infographics
Computer Science for Fun (cs4fn) has been writing about Machine Learning and Artificial Intelligence for over a decade. It includes articles on the underlying cmoputer science, novel applications and the ethical issues. All articles are aimed at school students.
Machine Learning for Kids provides a series of lessons for developing your own machine learning tools. It is based on Scratch. You can train the underlying Machine Learning engine on data, including images. This creates a series of specialist Machine Learning blocks you can use in Scratch. By copying the given code you can create a variety of applications.
Ken Kahn of Oxford University’s: A teacher’s guide to helping students build AI apps and artefacts includes an online chapter on Machine Learning where you can for example train a series of Machine Learning tools to recognize actions.
In the Channel 4 programme ‘Guy Martin Vs The Robot Car’ Guy Martin investigates autonomous vehicles, attempts to build a robotic Ford Transit, and takes on an artificially intelligent race car. What’s fastest, man or machine?
Eli Pariser’s TED Talk “Beware Online Filter Bubbles” looks at the problems of only seeing information that fits our world view. As web companies strive to tailor their services (including news and search results) to our personal tastes, there’s a dangerous unintended consequence: We get trapped in a “filter bubble” and don’t get exposed to information that could challenge or broaden our worldview. Eli Pariser argues powerfully that this will ultimately prove to be bad for us and bad for democracy.
Quick, Draw! is a Machine Learning experiment. Can a neural network learn to recognize doodling? Help teach it by adding your drawings to the world’s largest doodling data set, shared publicly to help with machine learning research.
Apply Magic Sauce from the University of Cambridge demonstrates the power of profiling. A personalisation engine accurately predicts psychological traits from digital footprints of human behaviour.
Super live example of data Internet live stats
This resource page has been set up as part of the PAMBAYESIAN project funded by EPSRC (EP/P009964/1) with support from the Network of Excellence.