Lesson 1: Introduction to Machine Learning
45 minutes
Overview
This lesson centers around the How AI Works: What is Machine Learning? video from the How AI Works video series. Watch this video first before exploring the lesson plan.
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 - AI Bot - is learning how to detect patterns in fish.
This lesson can be taught on its own, or as part of a 7-lesson sequence on How AI Works - click here to view all lessons in this sequence.
Standards
BI-3 - Computers can learn from data
3-A-ii - Nature of Learning - finding patterns in data
- 3-A-ii.3-5 - Model how supervised learning identifies patterns in labeled data.
3-A-iv - Nature of Learning - constructinv vs using a reasoner
- 3-A-iv.3-5 - Demonstrate how training data are labeled when using a machine learning tool.
AP - Algorithms & Programming
- 2-AP-17 - Systematically test and refine programs using a range of test cases.
IC - Impacts of Computing
- 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
- Introduction to Machine Learning - Slides
For the students
- Classifying Fish - Activity Guide
- How AI Works - Training Data and Bias - Video (Download)
- How AI Works - What is Machine Learning? - Video (Download)
Vocabulary
- Machine Learning - How computers recognize patterns and make decisions without being explicitly programmed
Teaching Guide
Before the Lesson
Getting Started with Code.org: Consider watching our Getting Started with Code.org video series for an overview of how to navigate lesson plans, setup a classroom section, and other important features of the Code.org platform. Each video also has a support article if you'd prefer to read or print instructions - click here to learn more.
Setup a Classroom Section: You can use a class section in Code.org to manage your students, view their progress, and assign specific curriculum - click here to learn more.
If you are using a learning management system, there may be additional steps to sync your classes with Code.org:
- Click here for steps to setup your classes with Google Classroom
- Click Here for steps to setup your classes with Clever
Become a Verified Teacher: Lesson plans and levels have additional resources and answer keys for Verified Teachers, which is quick process that verifies your position at an educational institution. Click here to complete a form and you should have access to verified teacher resources in ~1 business day.
Supports for Teachers: You can learn more about bringing AI lessons to your classroom through our AI 101 for Teachers series. AI 101 for Teachers is a free, foundational online professional learning series for any teacher and educator interested in the groundbreaking world of artificial intelligence (AI) and its transformative potential in education.
Warm Up (10 minutes)
Journal
Prompt: What’s an example of Artificial Intelligence (or AI) either in your personal life or that you’ve seen in a movie or book?
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. Students may gravitate towards examples of artificial intelligence whose form also mimics a human being, such as interactive robots or Siri or having a conversation with ChatGPT, but also emphasize examples that broader and more embedded in tools we use frequently, such as social media algorithms or streaming recommendation algorithms.
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: Show students the How AI Works - What is Machine Learning? video in the slides
Videos are used throughout the curriculum to spark discussions, supplement key concepts with additional explanations and examples, and expose students to the various roles and backgrounds of individuals in computer science.
While interacting with the video, turn on closed captioning so students can also read along as they watch.
To encourage active engagement and reflection, use one or more of the strategies discussed in the Guide to Curriculum Videos.
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.
Activity (30 minutes)
Remarks
In today’s activity, we’re going to use machine learning to help a robot clean up the ocean. To do this, we need to teach the robot to recognize fish so it will clean up anything that isn't a 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.
Real-World Influence: This type of technology is being used in the real-world by groups such as The Ocean Cleanup, which have used artificial intelligence and machine learning to train robots to recognize plastics in the water. You could consider showing this short video to the class as a way to further motivate today's activity: How AI Helps Clean Oceans From Plastics
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:
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.
Activity | As a Class |
---|---|
Training Screen ![]() |
|
Testing Screen ![]() |
|
Evaluation Screen ![]() |
|
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.
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.
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.
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 untrue about 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. 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)
Video: Show students the video in the slides How AI Works - Training Data and Bias
Journal
Prompt: What's a situation where it it might be helpful to use machine learning to solve a problem?
Encourage students 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 you teach additional lessons within this unit, you can refer back to these post-its as these topics are covered in other lessons.
After the Lesson
Teacher Survey
We'd love to learn more about the folks teaching these lessons and the classroom experience. Please let us know in this How AI Works Teacher Survey.
Additional Lessons
If you'd like to teach additional lessons from the How AI Works video series, click here to explore additional resources
AI and Machine Learning Unit
If you'd like to dive even deeper into AI and Machine Learning, consider exploring our 5-week unit on AI and Machine Learning. Click here to view the unit and learn more
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.