Lesson 15: Mini-Project: Make a Machine Learning App
45 minutes
Overview
In this one or two day mini-project, students apply their skills from the unit so far and create a machine learning app using real-world data. Students are provided with several real-world datasets from a variety of contexts, and they choose which dataset they would like to investigate. They train and save their model, then make a simple App Lab app that uses the model. This mini-project is an opportunity to assess how well students can use features to create accurate machine learning models, and how well they can create apps that use machine learning.
Question of the Day: Can I use real-world data to create an app that uses machine learning?
Assessment Opportunities
A rubric is provided to assess the mini-project
Standards
BI-3 - Computers can learn from data
3-A-ii - Nature of Learning - finding patterns in data
- 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 - Nature of Learning - training a model
- 3-A-iii.6-8 - Train and evaluate a classification or prediction model using machine learning on a tabular dataset
3-C-i - Datasets - feature sets
- 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 - Datasets - bias
- 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.
AP - Algorithms & Programming
- 2-AP-19 - Document programs in order to make them easier to follow, test, and debug.
DA - Data & Analysis
- 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.
Agenda
Objectives
Students will be able to:
- Create a machine learning model using a real-world dataset
- Create an app that uses a machine learning model
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
- Make a Machine Learning App - Slides
For the students
Teaching Guide
Warm Up
Get Started
Start Right Away: Get students started on this project right away so they have time to finish. Even though this mini-project is scheduled for only a single class period, you can consider spreading this project out over two days - one day for training a model and making a model card, and one day for customizing the app.
Distribute: Pass out a copy of Create an ML App - Project Guide to each student.
Display: Show students the slide with the Overview of the project. Read through the overview on the project guide and through the next few slides.
Activity (40 minutes)
Code Studio: Have students log into Code Studio and open the first level. Students can choose from several real-world datasets to train a model.
Circulate: Monitor students as they walk through the project guide. Slides are provided with the same instructions to help focus and direct students as they work.
Step 1 - Examine Your Data: Students will choose a dataset from the provided list in AI Lab
Step 2 - Train your Model: Students will choose at least 2 features to train their model. They will record their choices on their project guide.
They should aim to get at least 70% accuracy to earn full credit on the rubric.
Slight Changes in Accuracy: Students may notice that if they train on the exact same features over and over again, they may get slightly different accuracy calculations each time. This is because, in this level, AI Bot is randomizing the 10% testing data rather than always using the last 10% of the dataset. This is typically how machine learning accuracy is calculated with real-world datasets, since it avoids issues where the end of the dataset may not represent the entire data.
If students ask about this, you can use a similar explanation as above - that AI Bot is randomizing the testing data each time. This also means students may get slight variations in their accuracy, but the model being created is still essentially the same.
Step 3 - Save Your Model, Create a Model Card: Students will create a model card in AI Lab and save their model. They will also record some of their answers on their project guide.
Step 4 - Create Your App: Students will create their app in App Lab. Apps should have at least a theme and a welcome screen to earn full credit on the rubric.
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 5 - Reflect: Students will reflect on their model and how it could be improved. Students should also review the rubric to verify they met all of the requirements for the project.
Wrap Up (5 minutes)
Submit Projects
Make sure students submit their projects in App Lab. Collect their project guides to review along with the project rubric.
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. Some questions are the same as the pre-survey at the start of the unit, which can show student growth or changes in student attitudes towards computer science.
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.