< Unit 7 - AI and Machine Learning

Lesson 21: Design an AI App

225 minutes

Overview

To conclude this unit, students develop an AI app that addresses the social issue they have returned to throughout the unit. After looking at a sample app, students follow a project guide to complete this multi-day activity. In the first step, students prepare the data they will use to train their model in AI Lab. After training, testing, and generating a model card, they export their model into App Lab for development. Here they use their model to create a user-friendly app based on their mockup from the previous lesson, “Planning Your App”. Students perform a peer review and make any necessary updates to their projects before preparing a presentation to the class.

Question of the Day: How can I create an AI App the solves a problem in my community?

AI4K12 National Guidelines 2021
      • 3-A-ii.9-12 - Use either a supervised or unsupervised learning algorithm to train a model on real world data, then evaluate the results.
      • 3-A-iii.6-8 - Train and evaluate a classification or prediction model using machine learning on a tabular dataset
      • 3-A-iv.9-12 - Illustrate what happens during each of the steps required when using machine learning to construct a classifier or predictor.
      • 3-C-i.6-8 - Create a dataset for training a decision tree classifier or predictor and explore the impact that different feature encodings have on the decision tree.
      • 3-C-iii.6-8 - Explain how the choice of training data shapes the behavior of the classifier, and how bias can be introduced if the training set is not properly balanced.
CSTA K-12 Computer Science Standards (2017)
    • 2-AP-11 - Create clearly named variables that represent different data types and perform operations on their values.
    • 2-AP-12 - Design and iteratively develop programs that combine control structures, including nested loops and compound conditionals.
    • 2-AP-13 - Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
    • 2-AP-19 - Document programs in order to make them easier to follow, test, and debug.
    • 2-DA-08 - Collect data using computational tools and transform the data to make it more useful and reliable.
    • 3A-DA-12 - Create computational models that represent the relationships among different elements of data collected from a phenomenon or process.
    • 3B-DA-05 - Use data analysis tools and techniques to identify patterns in data representing complex systems.
    • 2-IC-22 - Collaborate with many contributors through strategies such as crowdsourcing or surveys when creating a computational artifact.

Agenda

Objectives

Students will be able to:
  • Apply the Problem Solving Process to create an AI for Social Good App

Preparation

  • Ensure students have copies of their “Lesson 2: AI for Social Good” and “Lesson 19: Planning Your App” handouts.
  • Print copies of the Project Guide.
  • Print copies of the Rubric.
  • Print copies of the Peer Review Guide.

Links

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

For the teachers
For the students

Teaching Guide

Day 1 (45 minutes)

Warm Up

Prompt: What is an issue you'd like to address with machine learning?

Discussion Goal: This is a big question! Have students journal individually, but don't have them share as a full group. Instead, use this to transition into the main activity where students will begin a project to create a machine learning app.

Remarks

Throughout the unit, we’ve tackled each part of building an AI app individually. For the next few days, we’re going to use the Problem Solving Process to see an entire project through. We're going to decide on an issue we want to address, design a survey, collect data, then use AI Lab to analyze that data and create a machine learning app.

Question of the Day: How can I create an AI App the solves a problem in my community?

Activity

Distribute: Give students copies of the Design an AI App - Project Guide.

Overview: Read through the Overview of the project with students and answer any questions.

Step 1 - Choose an Issue Statement

Do This: Have students brainstorm an issue statement they would like to address with machine learning. Encourage students to use the 5 Why's strategy from the previous lessons. You may even decide to have some copies of the 5 Why's - Activity Guide available for students.

Teaching Tip

Issues vs Problems: Encourage students to think broadly and consider issues they would like to address, since these are more likely to have solutions that can use data and machine learning. If students focus too narrowly on specific problems, they may have chosen something where machine learning may not be an appropriate solution. If you notice a student has a too narrow issue, encourage them to use the 5 Why's strategy to investigate the core issue and broaden their options.

Step 2 - App Planning

Do This: Have students brainstorm types of apps they can use to address their issue. They can research potential apps that they could use as inspiration

Teaching Tip

Flexibility: It's important for students to come up with at least once option in each box, so they have some flexibility later on if they need to pivot when developing their app. Encourage students to really brainstorm here, rather than putting all of their hope in a single app idea.

Timing: Students should finish Step 1 and 2 today, and potentially start on Step 3. If not, students can begin Step 3 today.

Wrap Up

Collect: Collect Project Guides and look over them for any issues that could cause problems for students in the next portion of the lesson. Students may also use the time before the next lesson to brainstorm additional app ideas.

Day 2 (45 minutes)

Warm Up

Distribute: Re-distribute the Project Guides from yesterday. If you have any feedback for students, make time to talk to them individually. Otherwise, students can jump straight into the next step for their project.

Step 3 - Plan Your Data Collection

Do This: Have students begin brainstorming how they will collect data and ensure they have enough data and a representative sample of data. Remind students of the previous lesson where students had flawed datasets and weren't able to train accurate models - this section of the project guide help them avoid those types of mistakes in the future.

Step 4 - Create Your Survey

Do This: Have students make a copy of Survey Template [Google Form]. This is the same template from the previous lesson to create their survey. Students can re-watch the video on how to use the template and make sure their data is protected.

Students should create their survey in Google Forms. Once the survey is ready, they can plan how they would like to distribute it. Once students reach this stage, they may need to pause while people complete their survey and they collect data.

Teaching Tip

Pausing to Collect Data: Even though this project is scheduled for a week, it may be worthwhile to extend the project so students can collect enough data for their surveys. You might consider planning some supplemental activities while students are collecting data, then regrouping back to the project once their data is collected. AI4All offers several Bytes of AI activities that can fit as supplemental lessons while students collect data.

Wrap Up

Collect: Collect students’ project guides and model cards. Do a quick check-in to make sure students are on track.

Day 3 (45 minutes)

Warm Up

Distribute: Re-distribute the Project Guides from yesterday. If you have any feedback for students, make time to talk to them individually. Otherwise, students can jump straight into the next step for their project.

Step 5 - Data Reflection

Do This: Students should analyze the results of their survey and record their answers in their project guide.

Step 6 - Train Your Model

Do This: Have students train their model in AI Lab. Students should download their survey data as a csv and upload it to AI Lab. They can re-watch the videos from previous weeks as a reminder of how to do this.

Teaching Tip

Adapting to Troublesome Data: Steps 5 and 6 are key moments in determining if the survey students designed and the data they collected can be used to create a machine learning model. There are a variety of factors that could make this difficult, especially if students didn't have a chance to collect enough data or the data doesn't lead to accurate models. Here are some strategies to help students move past these issues:

  • Documenting in the Model Card: Even if the data doesn't appear to create an accurate model, students can still use this data to complete the project as long as they document their decisions in the Model Card, especially in the Limitations section. Even though this means they are creating an app without an accurate model, it provides an opportunity for reflection on what could have gone differently in a future project.
  • Use a pre-supplied dataset: Several datasets are available in AI Lab for students to use if their survey data isn't leading to fruitful results. Students can use one of these datasets instead to complete their project. This may require adjusting the focus of their app, but students will at least be able to complete the project
  • Exploring Advanced Datasets: AI Lab is designed to work with machine learning datasets from several common websites, such as Kaggle. Students can explore this website to find a dataset that fits their needs, then use the dataset in AI Lab to train their model. An account is required to download datasets - we recommend having a teacher create an account and manage downloading datasets for students.

In general, this project focuses on students' ability to plan and execute an AI app that addresses an issue they care about, from ideation to data collection to app creation. Completing this cycle is ultimately more important than having an accurate app, especially since students have previously completed the mini-project which focuses more on training an accurate model and since students can document the intended uses and limitations on a Model Card.

Complete a Model Card: Once their model is trained and saved from AI Lab, they should spend time creating the model card for their data. You can provide two options for students to create their model card:

  • Model Card - Printable Template - You can print out a model card for each student, or provide poster paper for a student to use to create their model card. They should use previous model cards as examples of what to include. Students can also use post-its or notecards to complete the Label and Features section of their model cards. These cards can then be displayed around the room as a tangible representation of their work during this unit
  • Model Card - Digital Template - Have students make a copy of the Model Card digital template that they can edit. Any italicized text in [brackets] can be replaced with their own words. They can also create copies of the digital post-it notes for the Label and Features screen. These digital versions can be posted on a virtual gallery along with their apps as a way to represent their work during this unit.

Wrap Up

Collect: Collect students’ project guides and again do a quick check-in to make sure students are on track.

Day 4 (45 minutes)

Warm Up

Distribute: Re-distribute the Project Guides from yesterday. If you have any feedback for students, make time to talk to them individually. Otherwise, students can jump straight into the next step for their project.

Step 7: Develop Your App

Do This: Have students develop their app in App Lab. A rubric is provided to guide students through what their project should look like. At the very least, it need to have:

  • A design theme
  • A welcome screen
  • Descriptive feature and label text elements
Teaching Tip

Design Elements Off the Screen: Depending on the number of features that your students use in their model, some of their design elements may appear off of the screen. This tends to happen when using more than 6 features in a model.

There are two strategies you can use to help students fix this:

Strategy #1: Make New Elements. Students can use design mode to drag out new elements to use in their app. They may also decide to move the elements to different screens to help make the app easier to use. After adding these new design mode elements, students will need to update their code to use the new elements as well. Students can refer to Lesson 13, especially level 1, as an example of how to update their code to fix this problem.

Strategy #2: Reposition Elements. Even though the elements are off the screen, you can use Design Mode to manually select them and re-position them so they are on the screen. This involves changing the y-position property to 0 so it is on the screen, and then re-arranging the element like you would normally.

Step 8 - Test and Reflect

Do This: Before students leave, encourage them to find at least one intended user of their app to get some feedback. Students can fill in the testing information with their user, then fill in the reflection during the next class period.

Wrap Up

Collect: Collect students’ project guides and again do a quick check-in to make sure students are on track.

Day 5 (45 minutes)

Warm Up

Distribute: Re-distribute the Project Guides from yesterday. If you have any feedback for students, make time to talk to them individually. Otherwise, students can jump straight into the next step for their project.

Step 8 - Test and Reflect

Do This: Have students fill out the Test and Reflect section of their activity guide.

Teaching Tip

Timing: It's hard to predict the timing of this project considering all the directions that student projects could go in. Some students may get excited by the data collection and analysis piece, others may get excited by the app creation piece, and others may be struggling to find data that supports their creative ideas.

Consider this final day as a flexible day, where students can finish up whichever aspects of their project are in the most need. You may also consider extending this project if student interest leads to more projects and data to support their community.

Wrap Up

Submit Projects: Have students submit their projects on Code Studio

Collect: Collect student projects and supporting resources:

  • Project Guide
  • Model Card

Reflection

Send students to Code Studio to complete their reflection on their attitudes toward computer science. Although their answers are anonymous, the aggregated data will be available to you once at least five students have completed the survey.

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.