Lesson 2
Using maching learning to spot the shark
The aim of this lesson is to get students to build their first ever machine learning model using Google's Teachable Machines. This is a fun task where students work in groups or pairs to "Spot the Shark" by developing an image classification model to identify dolphins and sharks.
Overview
LESSON INTENTIONS
-
Build an image classification model using Teachable Machines to identify images of dolphins and sharks
-
Learn difference between training and test data
-
Understand how to evaluate what is a good machine learning model
MATERIALS
-
Laptops with Webcams (1 per group or pair - e.g. 20 students = 10 laptops)
-
Pen/pencil & paper
-
Scissors (To cut out images of sharks / dolphins)
-
Printer (To print out shark / dolphin images
-
Lesson 2 Slides
Preperation
* If you have not already, download the Lesson Materials using the link at the top of the page before continuing.
To prepare for this lesson, you will need to first print the image datasets in order for them to be used in the lesson. The images are split into "Training" and "Test" data. It is really important to not get these mixed up. In the lesson materials there is a PDF called train-images.pdf containing 4 specific images of Dolphins and 4 specific images of "Sharks". Examples of the training data are shown below. Print off one pdf sheet of train-images.pdf per student pair or group. These are the images that the student should train the image classification model with.
Similarly in the lesson materials, there is a file test-images.pdf containing another 2 specific images of Dolphins and 2 specific images of sharks. Again print of enough test-images.pdf copies per student pair or group. These are the images that the students should test the image classification model with.
Training Data
Testing Data
Slides: Introduction (5 minutes)
* If you have not already, download the Lesson 2 slides above or in the lesson materials.
MACHINE LEARNING RECAP
In TryAI we try and start all lessons by making an explicit connection between what students will be learning and what they are already familiar with. This is one of the recommendations from the gradual release of responsibility model. Therefore, in the introduction of Lesson 2, ask students to recap on the three processes in building machine learning that they learned in Lesson 1: input data, model and predictions.
Main Activity: Teachable Machines (35 minutes)
* If you have not already, download the Lesson 2 slides above or in the lesson materials.
This activity is meant to be delivered with excitment and enthusiasm. Slides 3-5 introduce the background to the activity and a summary is as follows.
A
ACTIVITY DESCRIPTION
Students have been recruited to create a machine learning model to identify dolphins and sharks. It is summer time and there is an imaginary beach where lots of people like to swim. However, there is a problem. The beach is also very popular with dolphins and sharks. This is a big problem because if a shark is detected then beach goers need to be told to get out of the water. The coast guard have asked YOU (the students) for your help - can you build an image classification model to spot the shark?
How to use Google's Teachable Machines to classify images of sharks and dolphins
Preparing the Training Data
IMPORTANT STEPS - HOW TO TRAIN THE MODEL
-
Get students to the Teachable Machines link above (or here) - https://teachablemachine.withgoogle.com/train/image
-
Cut out images of dolphins and sharks from the TRAINING SET to train the image classification model
-
Click on the pen next to "Class 1" and change name to "Shark"
-
Select "Webcam" button under "Shark" and press "Hold to Record" whilst showing an image of a shark from the training data
-
Now repeat this for all images of sharks in the training dataset
-
Click on the pen next to "Class 2" and change name to "Dolphin"
-
Select "Webcam" button under "Dolphin" and press "Hold to Record" whilst showing an image of a dolphin from the training set
-
Now repeat this for all images of dolphins in the training dataset
-
Finally, once all the steps above are complete, then press "Train Model"
Training the Model
WELL DONE! We have trained our first machine learning model - cool huh?
Now we want to test it out our model on new "unseen" testing data.
IMPORTANT STEPS - HOW TO TEST THE MODEL
-
Cut out images of dolphins and sharks from the TEST SET to test our new image classification model
-
Now show the test images to the webcam and see the prediction in the bottom right
-
Take note of what images it classifies as shark and dolphin? Is the model correct?
Discussion (5-10 minutes)
Once students have developed a working machine learning model and groups have completed the task, then breakout into a classroom discussion. Ask students do they think the machine learning classifier was good? Did it correctly classify all images of dolphins and sharks? Hint: Some of the images should be misclassified. If images were misclassified why? E.g. photos of dolphins showed lots of teeth and model thought it was a shark. Also, comment on the fact that the model was even able to identify hammer-head shark even though it was images of great white sharks in the training set.