Lesson 4: Patterns in Data
45 minutes
Overview
In this lesson students will examine several apps that make decisions about what shoes to wear, ultimately building up to an understanding of how machine learning can help make this decision. Students are guided to the conclusion that surveying their users can help them make the best decision by looking for patterns in the data and basing their decisions on these patterns.
Question of the Day: What strategies do computer models use to make decisions?
Assessment Opportunities
-
Describe how a model makes a decision (for example: with randomness, or a decision tree, or using data)
Use class discussions as a way to assess how well students understand the different ways computers can make decisions
-
Look for patterns in data to help make a decision
See the activity guide for this lesson.
Standards
BI-3 - Computers can learn from data
3-A-ii - Nature of Learning - finding patterns in data
- 3-A-ii.K-2 - Identify patterns in labeled data and determine the features that predict labels.
3-C-i - Datasets - feature sets
- 3-C-i.K-2 - Create a labeled dataset with explicit features to illustrate how computers can learn to classify things like foods, movies, or toys.
DA - Data & Analysis
- 2-DA-09 - Refine computational models based on the data they have generated.
Agenda
Objectives
Students will be able to:
- Describe how a model makes a decision (for example: with randomness, or a decision tree, or using data)
- Look for patterns in data to help make a decision
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
- Patterns in Data - Slides
- Shoe Survey - Resource
For the students
- Finding Patterns in Data - Video
- Patterns in Data - Activity Guide
Teaching Guide
Warm Up (5 minutes)
Journal
Prompt: Choose one question to respond to:
- When browsing the internet, what’s the weirdest thing an ad has ever tried to get you to buy?
- When sending a message, what’s the funniest thing autocomplete has suggested to finish a sentence?
Have students journal individually first, then discuss with a neighbor. Then invite students to share as a full class, and write a list of their answers where everyone can see it.
Discussion Goal: This is a playful prompt that invites students to make personal connections to their experience with AI, and consider the ways that AI can sometimes make incorrect decisions. Invite students to explore why these situations felt wrong and what information was incorrect or missing in how AI was making its decision. Once several examples have been shared, use the remarks below to transition to the activity.
Remarks
This is a great list, and it shows that computers make recommendations for us pretty often but they aren’t always very effective. Today, we’ll see how we can improve the way a computer makes recommendations. We’ll ask a computer to recommend what type of shoes we should wear for the day, and see several ways a computer might make this decision.
Question of the Day: What strategies do computer models use to make decisions?
Activity (35 minutes)
Display: Show students the slide revisiting the definition for model.
Remarks
Remember that a machine learning model is just a computer program designed to make a decision. In this lesson, we're going to look at several apps and try to understand the model they are using to make decisions. Some of these apps may be making decisions in very clever and sophisticated ways - and others... not so much.
Shoe Recommender
Code Studio: Have students log into the first level of Code Studio. This level contains a basic program that helps students decide what shoes to wear. Have students run the program a few times.
Discuss: Is this program helpful for deciding shoes? Why or why not?
Have students quickly discuss with a partner, then share out as a class.
Discussion Goal: This should be a quick discussion - students should predict that the program is randomly selecting shoes, which doesn’t make it a very good program for recommending shoes.
Display: Show students the basic description of this app, confirming that the model is just randomly making decisions.
Preview of Model Cards: The format used on this slide is a precursor to Model Cards, which students will see in later lessons. For now, you can describe these descriptions like a name tag or nutrition label on a model - it helps identify and describe how the model works for anyone who uses the app.
Discuss: What would improve this model to help it make better decisions?
Discussion Goal: Guide students towards the conclusion that this app could be improved if it used user input and asked questions to help it make decisions. Try to make connections back to the warm-up discussion and how apps can make bad choices when they don't have strong examples from their users. This will help connect to the next app that students will preview.
Improved Shoe Recommender
Code Studio: Have students continue to the next level in Code Studio, where there is another shoe recommender app. This one asks several questions before making a recommendation. Have students run the app several times, trying to determine how this model is making its prediction.
Discuss: How do you think this program is making its decision? Is it more or less helpful for deciding shoes than the last program?
Have students quickly discuss with a partner, then share out as a class.
Discussion Goal: Students may realize that they can only get certain answers based on certain decisions, and may intuitively describe some sort of “flow” through the program that leads to certain decisions. They may also question or criticize the decisions behind how some shoes are chosen. This is a good point to return to in a later discussion.
As students narrow-in on the branching structure of this app, show students the following slide which shows the tree that the app uses to make its recommendations.
Display: Show students the basic description of this app, confirming that the model is using a process called a Decision Tree to make its recommendations.
Discuss: Do you agree with the questions that were asked and how the shoes were assigned? Who do you think decided which shoes went with each answer?
Discussion Goal: Students might notice that some selections are hidden behind other choices that may not be ideal - for example, this model only has you wear sneakers when it’s raining and sports cleats when it’s not raining. Students may suggest that the tree needs to be rearranged based on their own experiences for when to wear shoes, or that these decisions may not represent all people who may want to use the app. Try to highlight this idea of getting input from our users to help make our decision, rather than relying on your own personal experiences since they may not represent all situations. This helps transition to the next activity.
Shoe Recommendation Survey
Code Studio: Have students continue to the next level in Code Studio, where they will take a survey asking several questions about their day and what shoes they are wearing. Students can take the survey multiple times to represent different situations, such as:
- Pretending it’s the weekend
- Pretending you’re going to a birthday party
- Pretending you’re sick and not feeling well
Once students have taken the survey, redirect them to the front of the room to see what happens with all of the data they've been generating.
Video: Show students the Finding Patterns in Data video.
Videos for Students: Videos are intended to be watched and discussed as a class, and so they are not provided as individual levels in Code Studio. If a student needs to re-watch a video, they can be found in the Help and Tips section of levels or by visiting the Student Resources page of each lesson.
Distribute: pass out the Patterns in Data Activity Guide to each student.
Do This: Have students complete the activity by finding patterns and trends in the data using the Cross Tab charts. An answer key is provided for you to check answers.
Circulate: Monitor students as they complete this activity guide. The sentence starters for each table should correlate with the hot spots in the data, while the final two answers can be more open ended and depend more on how well students justify their answers.
Formative Assessment: As you see students filling in the sentence starters, ask them to explain why they picked these two answers. Students should be able to refer back to the data and use the row to highlight how choosing a particular answer has a strong relationship with a certain shoe.
Share Out: Using trends from all five questions, what are some shoes we can recommend based on the patterns in the data?
Discussion Goal: Students should combine several trends together to help recommend a shoe. For example, if someone says they'll spend time indoors, with sunny weather, wearing socks: then we can recommend tennis shoes to this person. Have several students share and try to hear recommendations for each type of shoe. If possible, record some of the responses at the front of the room to use in the next level.
Vocabulary: Display a slide to remind students of the following definitions
- Feature: an input that the model uses to make decisions
- Label: the output you are trying to decide or predict with a model
Emphasize that in this data, each of the questions are the features which are being used to predict what type of shoe to recommend, which is the label.
Display: Show students the description of the app they’re about to look at, which uses the data shown to make its recommendations. Highlight that this app has a new section about the data that it used to create its model.
Code Studio: Have students continue to the next level in Code Studio, where this app is available to test. Have students answer the questions and see if the recommendations match what they saw in the data.
Display: Advance to the next slide, which shows an arrow connecting how Data becomes a Model. With this slide displayed, transition to the remarks below.
Remarks
Today, we saw how you can take data and use it to help create a model that makes recommendations. But analyzing that data took some time, even for a short survey like this - imagine if there were 20 questions instead of 3! Or if you were recommending a whole outfit instead of just shoes! In the next lesson, we’ll see one of the strategies that a computer uses to make it easier to turn data into a model.
Wrap Up (5 minutes)
Journal
Prompt: If you could add another question to the shoe survey, what question would you ask? Why do you think that question would be helpful in deciding a shoe?
Have students journal individually, then share with a partner. If time remains, invite a few students to share with the class.
Discussion Goal: Students will have a variety of possible questions and it’s important to listen to their reasoning as to why that question is useful. Hopefully students will choose questions that they think will help separate the data - for example, a question that might strongly indicate tennis shoes or work boots versus sandals and crocs. This bridges to tomorrow’s activity, where we compare examples of questions that are helpful in making a decision versus ones that aren’t helpful.
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.
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.