< Unit 7 - AI and Machine Learning

Lesson 1: Introduction to Machine Learning

45 minutes

Overview

In this lesson students are introduced to a form of artificial intelligence called machine learning and how they can use the Problem Solving Process to help train a robot to solve problems. They participate in three machine learning activities where a robot - A.I. Bot - is learning how to detect patterns in fish.

Question of the Day: How can we use the Problem Solving Process to solve a problem with machine learning?

Assessment Opportunities

  1. Apply the Problem Solving Process to train a computer to solve a problem

    Check student responses on the activity guide at the end of the class period.

AI4K12 National Guidelines 2021
      • 3-A-ii.3-5 - Model how supervised learning identifies patterns in labeled data.
      • 3-A-iv.3-5 - Demonstrate how training data are labeled when using a machine learning tool.
CSTA K-12 Computer Science Standards (2017)
    • 2-AP-17 - Systematically test and refine programs using a range of test cases.
    • 2-IC-21 - Discuss issues of bias and accessibility in the design of existing technologies.

Agenda

Objectives

Students will be able to:
  • Apply the Problem Solving Process to train a computer to solve a problem

Preparation

  • Review the Code Studio levels before the lesson
  • Print copies of the activity guide for each student

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the teachers
For the students

Vocabulary

  • Machine Learning - How computers recognize patterns and make decisions without being explicitly programmed

Teaching Guide

Before the Unit

This unit assumes students are already familiar with the design elements of App Lab and the onEvent and setScreen commands - essentially what is covered in Unit 4 of CS Discoveries or the App Lab Hour of Code tutorial. Students will use App Lab for the first time in Lesson 7.

If you have students who have not worked in App Lab and Design Mode before, you may consider spending some additional class time introducing just enough App Lab to students for them to be successful in this unit. Click here to read our recommendations for how to do this.

Warm Up (10 minutes)

Journal

Prompt: Today we begin a unit on Artificial Intelligence, or AI. What’s an example of AI either in your personal life or that you’ve seen in a movie or book?

Teaching Tip

What Is AI? At a basic level, artificial intelligence is when a computer program mimics the intelligence of a human being. This can appear as solving a problem, engaging in conversations, displaying emotions, and many other forms. Shortly after this prompt, students will watch a video that further defines AI and the focus of this unit, Machine Learning.

Have students brainstorm silently on their own, then share with their neighbors, and finally share with the whole class.

Discussion Goal: Try to surface any personal connections students may already have with AI. Students may come up with examples from their personal lives, such as recommendation systems or facial recognition. Or they may think of examples in the media, such as the robots in movies like Wall-E or personal assistants like Siri. Students may also come up with examples that aren’t strictly AI - for now, add them to the list anyway. Keep track of any suggestions that students surface without validating them as right or wrong - let students brainstorm freely first.

Display: Display the slide with the large venn diagram that includes AI and many applications.

Remarks

Artificial Intelligence is used in a lot of different places in our lives - from facial recognition in our phones to personal recommendations when we browse the web, and even in driverless cars. For the next few weeks, we’re going to focus on a specific type of artificial intelligence called machine learning.

Video: Watch the AI: What is Machine Learning? video in the slides

Vocabulary: Display the following vocabulary

  • Machine Learning: How computers recognize patterns and make decisions without being explicitly programmed

Remarks

Machine learning helps us solve important problems in society. In the next few weeks, we’ll look at how we can create our own machine learning apps to solve problems. To help accomplish our goals, we will use the Problem Solving Process - Define, Prepare, Try, Reflect, and always Empathize. Let's take a look at how these steps appear for Machine Learning in particular

Display: Show the slide with the Problem Solving Process. Read through the additional lines that represent how the process connects to Machine Learning.

Question of The Day: How can we use the Problem Solving Process to solve a problem with machine learning?

Activity (30 minutes)

Remarks

In today’s activity, we’re going to use machine learning to help a robot clean up the ocean and learn how to identify fish. We’ll give it lots of examples of fish, give it time to learn from those examples, and then see how well it does in cleaning up the ocean.

Distribute: Pass out the Activity Guide for this lesson

Level 1 - Recognizing Fish

Code Studio: In front of the classroom, navigate to Level 1 in Code Studio - Recognizing Fish.

Do This: As a class, go through this level which guides you through the process of training A.I. Bot to recognize fish. As you do, fill in the first part of the activity guide as a class. Consider the following strategies at different stages of the level:

Teaching Tip

A.I. Bot and Pronouns: These levels purposefully use A.I. Bot’s full name and avoid gendering A.I. Bot as “he” or “she”. Even though some AI systems take on personified gendered roles - such as Siri or Jarvis - actual machine learning programs don’t have genders because they’re just computer programs. Model this same behavior with students by referring to A.I. Bot by it’s full name or using “it” as its pronoun.

Training Screen:

  • Informational text will frequently pop up on the screen. Consider asking students to read the prompts aloud to the class, possibly in their best robot voice, for a little fun
  • Ask students to use thumbs up / thumbs down to decide as a class whether something is a fish
  • At 30 images, the level will ask if you would like to continue or keep training. Ask students to help with this decision and follow their lead - either continue training, or go to the next screen.
  • Before continuing, have students record on their activity guide how many images they used to train A.I. Bot.

Testing Screen:

  • A.I. Bot will probably misidentify a few objects. Make sure students notice this, and ask them to individually consider why they think this might be happening. This ties in to the discussion at the end of this level.

Evaluation Screen:

  • Have students count the number of fish that it identified correctly. Record this on the activity guide.
  • It’s okay if A.I. Bot misidentifies some trash as fish - this sets the stage for the discussion.

Discuss: If we wanted A.I. Bot to become better at recognizing fish, how do you think we could help it do that?

Discussion Goal: Help students understand that A.I. Bot learns better when it has more examples. The best way we can improve its ability to recognize fish is by giving it more examples to look at. Students may also make the connection that this is how humans learn, especially young children - the more examples we have, the better we learn.

Remarks

This is one example of how the Problem Solving Process and Machine Learning can be used to solve a problem. We prepared our data, used it to train A.I. Bot, then reflected on the results and decided what to do next. In this next level, you will follow this process and train A.I. Bot to detect certain kinds of fish - like red fish or blue fish or triangle fish.

Level 2 - Recognizing Fish Features

Code Studio: Have students navigate to Code Studio Level 2 - Recognizing Fish Features. This level lets students train A.I. Bot to recognize a fish by its color or body type.

Do This: Have students choose a word that they want to train A.I. Bot to recognize, and record this information on their Activity Guide. Students should progress through the level on their own, recording information on their activity guide.

Circulate: Check that students are filling in their activity guide as they complete the stages. After briefly checking in with each student, complete this stage yourself in front of the room and pause at the last screen.

Teaching Tip

Activity Guides and Code Studio: Students may struggle initially to keep track of information on their activity guide as they complete levels in Code Studio. One way to help students think about this is similar to being a scientist performing a lab experiment: they are performing an experiment in Code Studio, and keeping track of their results in their Activity Guide. This is a pattern that will continue throughout the unit, so this is a great opportunity to help students manage both the activity guide and Code Studio.

Display: As students reach the final stage, have them press the white Information icon in the upper-right corner. This displays the features that A.I. Bot is using to help make its decision. In the example here, A.I. Bot has learned that the color matters the most when making a decision and the eyes matter the least.

Have students record the most important and least important features on their activity guide.

Discuss: What features did A.I. Bot think were the most important? Are those the features you were expecting to be most important?

Discussion Goal: Students may find that A.I. Bot thinks some features are important when they’re actually completely unrelated to their word. For example, thinking that the mouth of a fish is important when trying to determine if the fish is red. Students can verify this by looking for patterns in the fish that A.I. Bot has accepted - maybe all of their example fishes happened to have the same type of mouth and A.I. Bot mistakenly thought this was important.

Remarks

Some of you noticed that A.I. Bot was learning about parts of the fish that aren’t actually important, like the mouth or eyes or dorsal fin. This happens in real life too - machines can learn patterns we don’t intend even with lots of data, which can cause A.I. Bot to make mistakes. For this situation, it’s pretty easy to tell if A.I. Bot made a mistake - we can quickly see if a fish isn’t actually red or circular. Let’s try a slightly harder challenge - trying to recognize expressions!

Level 3 - Recognizing Fish Expressions

Code Studio: Have students navigate to Code Studio Level 3 - Recognizing Fish Expressions. This level lets students train A.I. Bot to recognize a fish by its expression, such as “silly” or “serious” or “angry”.

Do This: Have students choose an expression that they want to train A.I. Bot to recognize, and record this information on their Activity Guide. Students should progress through the level on their own, recording information on their activity guide. On the final screen, have students press the information icon and record the features that A.I. Bot learned were most important.

Circulate: Check that students are filling in their activity guide as they complete the stages. Ask students what features they’re looking at to determine if a fish meets their criteria. Students will probably say they primarily use eyes and mouth to help determine expression, but when they click the Information icon on the final screen, A.I. Bot may be using additional features such as color and body to make its decision. Prompt students to think about how they feel about this and compare it to their personal experience - For example, if someone thought they were “silly” or “angry” primarily based on their clothing.

Display: Show the slide of A.I. Bot learning how to identify fish as “Angry”. Have students discuss the prompt on the screen: Looking at this screen, why do you think color appeared as the second most important feature?

Discussion Goal: Students should notice that even though the eyes and mouth tend to appear “angry” on every fish, there also appears to be a lot of purple fish on the screen. As a result, A.I. Bot may start to think that the color “purple” is another way to tell if a fish is angry or not.

Discuss: Do you think it’s okay to consider a fish “angry” by its color?

Discussion Goal: For the first part of the question, guide students to notice that there are a lot of purple fish on the screen so A.I. Bot might think that purple fish are more likely to be angry than other fish.

Teaching Tip

Job Interviews: If there is time available, consider showing students Objective or Biased: On the questionable use of Artificial Intelligence for job applications. This is a real-life example of a similar situation where unintended factors, such as wearing glasses or a headscarf, are influencing how an AI system rates job applicants. This can be a useful resource to make a connection between this fish activity and the real-world, but this resource is not designed for a middle-school audience and requires some adjustments and decisions for how to best present to your students.

The second part of the question is more open-ended. Students should explore their own ideas and feelings about whether this kind of labeling is appropriate based on the color of the fish. In particular, A.I. Bot has learned “purple fish are angry fish”, which students may have strong reactions to. They may describe similar situations outside of the classroom, such as moments where they’ve been judged by their appearance, gender, or race, to help explain their opinions. This question is designed to start a conversation and connect students’ experiences to the potential pitfalls of machine learning, and it’s okay if the discussion doesn’t come to a firm conclusion. You can let students know that they will continue to learn about and discuss these issues in the rest of the unit. Use the remarks below to help wrap up the discussion.

Remarks

Even with a small example like this, we see that machine learning can get into trouble and learn something that’s harmful to a particular type of fish. Having more data and making sure it represents all types of fish can help solve this problem. These types of examples happen in real life too and can have serious consequences, such as whether or not you receive medical care or get a job offer. Throughout this unit, as we learn how to use machine learning to solve problems, we need to always be thinking about: What is the impact, and who is being included or excluded?

Wrap Up (5 minutes)

Reflection

Code Studio: Have students answer 5 quick survey questions at the beginning of this unit on AI and Machine Learning. Once at least 5 students have completed the survey you will be able to view the anonymized results in the Teacher Dashboard. Some of these questions will be asked again at the end of the first project, which can be helpful in seeing student growth and shifts in attitudes throughout the unit.

Journal

Prompt: What is something new you learned about machine learning today? What is a new question you have about machine learning?

Encourage students to choose one of these to share with you on the way out the door, or to write their responses on a post-it note that can be displayed in the classroom. If possible, keep track of these items throughout the unit and refer back to them in later lessons when they are addressed.

Lesson Feedback

Find a typo? Were some of the directions unclear? Have a suggestion for how to improve the flow of this lesson? We'd love to hear it! Please use the links below to provide feedback on this lesson.

Creative Commons License (CC BY-NC-SA 4.0).

This work is available under a Creative Commons License (CC BY-NC-SA 4.0).

If you are interested in licensing Code.org materials for commercial purposes contact us.