girls using hardware around a laptop

Using your AI Model in an App or Project

It’s time to put your trained model to work!

Dataset

Model
finds
patterns

Model
makes
predictions

Correct actions or decisions!

Which platform did you choose?

Click on the platform you trained your model with to learn more about how to add code to make your project take action! 

Tip: Choose one path and follow it. Do not do them all!

Teachable Machine just allows you to train an AI Model. There are many platforms that will allow you to use that model to make something.

  • If you are planning on making a Scratch project, we suggest RAISE AI Playground, from MIT, a version of Scratch, because it’s easy to add a Teachable Machine model .
  • If you are planning on making a mobile app, MIT App Inventor has an extension you can use to use the model in your app.

The first video shows how to use a Teachable Machine model for snap, clap, whistle sounds (Unit 5) in a Scratch project.

The next video shows you how to use a Teachable Machine image model to make a rock, paper, scissors game in App Inventor. If you need help making the model in Teachable Machine using images, this video will walk you through it. 

With models made with Machine Learning for Kids, you can make a
  • Scratch project
  • Python project
  • Or a mobile app with App Inventor

In this video, you’ll learn to take the Iris identification AI model from Unit 7, and use it in a Scratch project to display the correct iris picture based on sepal and petal measurements.

Models created with the App Inventor Personal Image Classifier or the Personal Audio Classifier can be integrated into a mobile app using MIT App Inventor. 

In this video, learn how to take your citrus identifier AI model from Unit 7, and add the model to an App Inventor project.

Now code the app so it identifies images of citrus to tell whether it’s healthy or diseased.

ACTIVITY: ADD MODEL TO YOUR PROJECT

  • Plan what actions you want your app or Scratch project to take.
  • Have your AI model ready.
  • Import it into the platform of your choice.
  • Code!
girls coding

Train your AI Model

Remember:
Healthy predictions need healthy data
!

Healthy
dataset

Finds
correct
patterns

Healthy
prediction!

Correct actions or decisions!

Do you remember what makes a healthy dataset?

  • Lots of data
  • Accurate
  • Matches your problem and solution
  • Different examples of data
  • The right kind of data
  • You have permission to use it

IT'S TIME FOR YOU TO START TRAINING YOUR DATA!

alarm clock
You should have gathered your data by now… or at least started!

WHETHER IT’S…

Your own training data from your community

and/or

Data gathered from sensors or user input

and/or

strings of numbers

Data collected from public datasets

Click on a platform name below to learn more and try out some tutorials.

teachablemachine.withgoogle.com
  • Train images, sounds or poses
  • teachable machine screenshotAttach devices to capture sensor data
Google’s Teachable Machine lets you easily train AI models that can be used with other platforms. In this video, learn a little about Teachable Machine and training an AI model that you can later used to make a Scratch project, or an app with MIT App Inventor.

Here are three tutorials to try out Teachable Machine using different data types.

machine learning for kids logo
  • Train images, sounds, text, or numbers
With your trained dataset  you can:
  • Make a Scratch or Python project
  • Or a mobile app with App Inventor
This video is an example of a Technovation team who created SkinClin, a Scratch project to detect skin diseases using Machine Learning for Kids.

This video is an example of a Technovation team using Machine Learning for Kids to make a mobile app to sort biomedical waste.

TRY IT YOURSELF!

In this video, see how to take the Iris public dataset from Unit 6 and train it using Machine Learning for Kids. 

Then in the next unit, you can use it in a Scratch project!

appinventor.mit.edu

  • app inventor bee logoTrain images, sounds, or poses
  • With your trained dataset you can make a mobile app that uses AI.

WANT TO TRY IT?

In this video, see how you can use the App Inventor image classifier to train an image dataset. This dataset classifies healthy fruit vs diseased fruit.

Then in the next unit, see how to use your model in a mobile app!

ACTIVITY: TRAIN YOUR MODEL

  • Choose the AI tool you want to use for your Technovation Project.
  • Add your examples.
  • Train and test your AI model.

Best practices: Training models is hard! Even Google gets it wrong. Their AI was trained but still started outputting wrong results! Don’t give up!

Guiding Questions to ask students: How accurate do you want your AI model to be? If it can not be 100% accurate, what is an acceptable answer? 80% of the time? Does that depend on the risk of what you are using the model for? For example self driving cars have to be pretty accurate otherwise they might hurt someone but google search results apparently have a much lower bar. 

Mentor tips are provided by support from AmeriCorps.

stylized A, AmeriCorps logo in navy
little girl taking picture

Collecting Data

 Remember,  healthy predictions need healthy data!

Healthy
dataset

Finds
correct
patterns

Healthy
prediction!

Correct actions or decisions!

 But what makes data healthy data? 

Can you make a list?

Healthy data

Lots of data

Accurate

Matches your problem and solution

Different examples of data

The right kind of data

You have permission to use it

Healthy prediction!

Better actions or decisions

THERE ARE 3 WAYS YOU CAN COLLECT HEALTHY DATA

Collect your own training data from

your community

Gather data with

sensors or user input

Use data from

public datasets

What path is right for you?

COMMUNITY

if the information you need is available from your community, and you can get permission to use it.

SENSORS

if you want your app to collect data on its own .

PUBLIC DATASETS

if you need lots and lots of data or you’re solving a problem that is more global.

COMMUNITY DATA

Plan: What type of data do you need from your community? How will you gather it?

survey checklist
Surveys
camera illustration
Take pictures
two people sitting in chairs talking
Make appointments
microphone
Record sounds

SENSOR DATA

Voice assistants like Siri or Alexa have a microphone, which is a sound sensor, to gather data (like what a person is saying)

This smart crosswalk has a light sensor to gather information about how light and dark it is and a motion sensor to detect movement.

man walking across street in dark with streetlights turning on

Different sensors gather different types of data!

Camera
Proximity sensor
Speedometer
Infrared thermometer
Light sensor
Microphone

HARDWARE OPTIONS

You will need devices to help you capture your data. Consider using:

Phone

Your phone has many sensors that can be used to gather information... Think mobile app!

arduino

Arduino

Small circuit board that can gather data and is built to use AI.

micro:bit

Small circuit board that can gather data and is built to use AI.

Raspberry Pi

Mini-computer (board) as powerful as a laptop!

For more, check out this big list of sensors.

This video from our World Summit 2020 has lots of great information on hardware options!

PUBLIC DATASETS

You might want to use a public dataset if …

puzzle
stack of books

You want more complete data.

You want to use a lot of data.

You want accurate data.

WHERE TO FIND PUBLIC DATASETS

Here are some good places to start. (Click images to visit sites.)

Here are some links to sample datasets according to problem types:

Here are some links to sample datasets according to problem types:

WHERE ELSE COULD YOU LOOK?

You can try:

  • local organizations
  • local schools
  • local libraries
  • where else?

It’s not easy finding the perfect dataset. Remember to ask for help!

The activity below is  practice in finding and using a public dataset and training a model using Machine Learning For Kids. The dataset has information about iris flowers, and the model will predict the type of iris based on length and width of flower parts.

ACTIVITY: TRAIN A MODEL

Follow the video below to use a public dataset in an AI model

In the next unit, we’ll use the iris AI model in a Scratch project!

DO THE BEST YOU CAN!

You may not be able to gather the perfect dataset, but gather what you can. 

Proxy data is data that is a placeholder for a later version of your dataset. 

JUMP IN AND STARTING PUTTING YOUR DATASET TOGETHER!

Check off these items to make sure you create a strong dataset!

  •  
image dataset

Healthy Datasets

DATA FUELS AI

Just like food fuels the human body!
Large collections of data are called datasets.

Healthy datasets
lead to correct actions with AI!
road leading straight ahead

Healthy datasets have lots of different examples!

many sound icons

IT'S IMPORTANT TO SPEND TIME GATHERING HEALTHY DATA!

 If your data is healthy …

Healthy
dataset

Finds
correct
patterns

Healthy
prediction!

Correct actions or decisions!

 If your data is not healthy …

Unhealthy
dataset

Finds
bad
patterns

Bad
prediction!

Incorrect actions or decisions!

But how do we make healthy datasets?

Healthy datasets

Lots of data

Different examples of data

The right kind of data

(example: not using pictures if sounds would be better)

Correct actions or decisions
happy face

REMEMBER OUR MAKE ME HAPPY MODEL?

happy sad dataset

How
healthy
was this dataset?

Finds
the right
patterns

Correct
prediction
for happy
or sad

Correctly shows a happy or
sad face

Is the Make Me Happy dataset healthy?

Does it have lots of data? Were there equal amounts in each class?

What different examples of data does it have? Could we have added more, different data?

Does it use the right kind of data? Why?

Makes the right decision about the type of sentence and displays the correct picture.
happy facesad face transparent background

Let’s check if the dataset is healthy!

More than 10 pieces of data means we are off to a good start with lots of data! 

We have different example sentences as our different types of data

Our model uses sentences, so a text dataset (happy and sad sentences) is the right kind of data!

Likely to make the right decision and display the correct happy or sad face!

Can you make the dataset for Make Me Happy better?

Healthy datasets

Lots of dataare there more sentences we can add to the training data?

Different examples of dataare there sentences in another language we should add?

The right kind of datainstead of text should we use audio clips (sound)?

You can make
an even better happy/sad recognizer!

Below are some activities to get you ready to work with datasets! First, you will judge some existing datasets to see if they are healthy, and then you’ll practice planning a dataset for a given problem.

ACTIVITY 1: JUDGE THE DATASETS

Download the file and fill out the worksheet

ACTIVITY 2: PLAN A DATASET

Download the file and fill out the worksheet
girls smiling at computer

Training an AI Model

Let’s explore how patterns can help AI make predictions and do actions.

Dataset >

finds patterns with learning algorithm  >

prediction to make  >

actions or decisions!

We’re going to learn how to make a Scratch project that uses AI to make a happy or sad face appear based on the sentence our user types!
 
In this activity you will create a dataset and use that to train an AI model to make a prediction.
 
An AI model is just another word for a dataset that has been trained and tested to correctly identify or label something. 
 
You will train the AI model to find patterns.

Dataset

Happy sentences and sad sentences

You will train your dataset with sentences that can be considered happy and others that can be considered sad.

happy sad dataset
happy face

OR

You will train and test your model on the website  machinelearningforkids.co.uk
 
And then you’ll use Scratch to make a project! Your project will use AI to make a happy or sad face appear, depending on what kind of sentence the user types.

ACTIVITY: HAPPY OR SAD

Follow the 3 video tutorials below to train your model and use it in a Scratch project.

In this first video, you’ll visit the Machine Learning for Kids website and make a non-AI Scratch project to start.

In this second video, you’ll make your dataset, then train and test it.

This is called supervised learning, because you are carefully watching how your model learns and fixing any issues.

In this third video, you’ll use your model in your Scratch project so the sprite can react using AI.

CONGRATULATIONS!

You’ve trained an AI model! You can always improve your model by adding more examples. Make sure you test your model if you do!

Now test yourself with the AI Models quiz.

girls looking at hardware device

How Does AI Work?

Let’s start to explore how Artificial Intelligence actually works!

There are THREE parts to Artificial Intelligence. 

DATASET

PATTERNS

PREDICTION

This video is all about the first part, datasets.

Stop and THINK

What ways do you and your family create data everyday using your computer or phone.

two girls talking
  • Every Google search
  • Words you type into emails
  • Every question you ask Alexa/Siri/OK Google
  • Connected devices – each time you turn on lights, change room temperature
  • Taps you make on your cell phone
  • Anything you buy online
  • Songs you listen to
  • Steps you take walking with your phone
  • Videos you watch

This next video will talk about the next parts of AI – patterns and predictions.

Stop and DISCUSS

How does Youtube suggest videos for you to watch? What are the dataset, patterns, and predictions for Youtube?

two girls talking

Dataset

  • Past videos you’ve watched
  • Videos other people watch
  • What you just watched

Patterns

  • Find videos that are watched by people who are like you
  • Find videos that other people watched after they watched a video like the one you just watched 

Prediction

  • A list of videos you might like to watch

ACTIVITY: HOW DOES AI WORK?

Use the worksheet to explore another AI technology and find out types of data it uses, what patterns it looks for, what predictions it makes, and actions it takes!

Stop and Discuss

Based on the activity:

  1. What did you learn about the data?
  2. Did anything surprise you?
  3. Was it hard to figure out which data the AI technology used? Why or why not?
two girls talking
girl holding phone over box and taking picture

What is AI?

This video will get you thinking about artificial intelligence, and how to tell whether something is AI or not.

Let’s play a game to see if we can tell what uses AI… and why!

DIRECTIONS

For each example, choose which one uses AI … and why! 


Base your answers on the questions below.

  • Does it understand or sense things?
  • Can it learn over time?
  • Can it make decisions?
  • Can it interact with humans?
  • Can it do it on its own or is it following commands?

EXAMPLE

Pick which one you think uses AI.

This alarm clock is set to go off every morning at 6:30am.

alarm clock

This smartwatch can recognize voice commands, monitor your activities and health and give you updates on your day.

This alarm clock is set to go off every morning at 6:30am. 
NOT AI!

alarm clock

This smartwatch can recognize voice commands, monitor your activities and health and give you updates on your day.   AI

READY? LET'S START!

QUESTION 1

Pick which one you think uses AI.

Vacuum

dog being vacuumed

Roomba

cat riding a roomba

Vacuum not AI

dog being vacuumed

Roomba  AI

cat riding a roomba

The Roomba learns the layout of the room and uses that information to plan its best course.

QUESTION 2

Pick which one you think uses AI.

Remote controlled cards

remote controlled cars racing

BMW i3 parking assistant

auto-assist car parking
image courtesy car-rev-daily.com

Remote controlled cars not AI

remote controlled cars racing

BMW i3 parking assistant  AI

auto-assist car parking

The BMW i3 uses AI to back the car into small spaces by using sensing and image recognition.

QUESTION 3

Pick which one you think uses AI.

Prosthetic that responds to user’s thoughts

man lifting objects with prosthetic arm

Prosthetic that responds to user’s movement

woman dancing with prosthetic leg

Prosthetic that responds to user’s thoughts  AI

man lifting objects with prosthetic arm

The prosthetic learns how to perform movement based on brain signals.

Prosthetic that responds to user’s movement  not AI

woman dancing with prosthetic leg

QUESTION 4

Pick which one you think uses AI.

Email predictor

Spell checker

spell checker

Email predictor  AI

predictive text

The email predictor learns what usually comes next when certain words are written.

Spell checker  not AI

ADDITIONAL RESOURCES

This video shows how AI can help people in many ways. It also shows how AI can be harmful to humans in some ways

girls coding

Web Apps Using AI Models

  • Train a machine learning model using Python libraries in a Jupyter Notebook
  • Incorporate a trained machine learning model into a Streamlit web app

These are the activities for this lesson:

WORKING WITH MACHINE LEARNING MODELS

Another major feature of Jupyter Notebooks, Python, and Streamlit is the ability to train machine learning models and make predictions. 

If you are new to Artificial Intelligence,  you might want to view the AI lessons in this curriculum to learn the basics before jumping into the more advanced coding involved here. You can use a user-friendly machine learning model platform like Teachable Machine to make a model and still incorporate it into a Python web app. 

If you have had some experience with artificial intelligence and working with datasets using Jupyter Notebooks, this is a good next step for you. 

In this lesson, you will learn about some of the Python machine learning libraries, and some of the different machine learning models you can create using Python. 

To review, to create a machine learning model, there are 3 main parts. 

DATASET

FINDS PATTERNS WITH LEARNING ALGORITHM


PREDICTION!

The dataset is your input for the model. It can include text, images, sounds, or poses. We worked with text and numerical data in Unit 2 using Jupyter Notebooks. We will continue to work with text data in this lesson, in the form of a spreadsheet.

Finding Patterns is essentially building the machine learning model using the dataset. Python contains many libraries that will build an AI model from data. In this curriculum, we will use many of the functions from the scikit-learn package. In addition to the libraries it provides, the website contains lots of excellent information about machine learning and the process of building models. It is a great resource to learn more!

Once you have created your model, the model can be used to predict an outcome based on new information. Once again, Python supplies libraries that enable this.

PREPROCESSING DATA

Before your dataset can be sent to the algorithm for building the model, it must be preprocessed, or “cleaned” so that the model building algorithm can work with it and make the most accurate model possible. In fact, the bulk of the work for creating a machine learning model is in the preprocessing. You will need to look carefully at the data to decide what is important, what can be left out, and what needs to be cleaned up.

What does preprocessing involve? With a text-based dataset, here are some things to deal with.

 

Null Values

Sometimes the dataset contains blank or null values, especially if the data is survey data. Sometimes you will eliminate any rows that have null data.

However, if the number of samples is low, you may not want to eliminate them. Another option is to replace a null value with some other value. It could be zero, or it could be the average of all the other values for that field.

Outliers

Sometimes the data contains one or two samples that are very different from the rest of the data. This might skew the model. You don't want the outliers to affect how the model is created, so often outliers are eliminated from the dataset.

For example, you might have a dataset where 95% of the samples are people aged 10-30, but you have a few random samples where the people are over 50. Since the vast majority of samples are in the 10-30 age group, you can consider removing the samples from the older age group.

Standardization

Often the numbers in a large dataset vary, depending on what features are represented. For example, you might have age, that varies from 0 to 70, but then you might have salary, that ranges from 0 to 500,000! The scales are very different, so one feature might count more in the model.

To fix, this, you can standardize the data so it's on a single scale. scikit-learn provides a StandardScaler, which updates each features so the mean is 0 and the standard deviation is 1.

Another thing to consider is a balanced number of samples for each class or label. You want to make sure their are about the same number of each class in your dataset.

Encoding

AI likes numbers, not necessarily words. So it helps to have all of the data converted to numbers. scikit-learn provides Encoder functions, so you can easily convert a range of possible text values to a range of numbers.

An example could be activity levels, with sample values sedentary, light, moderate, high. Those responses could be encoded to be values 0, 1, 2, and 3, which is much easier for the model building algorithm to handle.

SPLITTING DATA

Once you have preprocessed your data, you need to split it into a training set and a testing set. The training set will be used to train and create the model. Then you will test your model using the test set to see how it performs.

There are standard ways to split it (usually 75% for training, and 25% for testing) but you can split it however you want. Again, functions are provided so this is all automated for you. 

CREATING THE MODEL

The next step is creating the model. A big decision to make is, which algorithm do I use? There are many different supervised learning algorithms to choose from, and it is hard to know which one to use. A good process is to try out several different algorithms and then see which one gives you the best accuracy. 

The first step is to decide whether you need a classification algorithm or a regression algorithm. That depends on what you are trying to predict. 

Classification algorithms are used to predict discrete targets or classes. For example, classifying email as spam or not spam would be a classification problem

Regression algorithms are used to predict something that is along a continuous range. One example would be predicting how much salary a person will be paid. The prediction is a range of numbers and the output could be any value along that range. 

Here are just a few of the popular types of model creation algorithms.

neural network

Classification

  • Decision Tree
  • Random Forest 
  • K-Nearest Neighbors
  • Naive Bayes
  • Logistic Regression
  • Support Vector Machine

Regression

  • Linear regression
  • Ridge Regression
  • Lasso Regression
  • Polynomial Regression
  • Bayesian Linear Regression
  • Support Vector Regression

Note that some algorithms fall under both types. For example, there is a Decision Tree Classifier as well as a Decision Tree Regressor. And a Support Vector Machine works for classification, and Support Vector Regression works for regression. 

So, how do you decide which one to use? You should research to see what other data scientists use for different situations to see what might for for your model. You should also try out some different algorithms with your data and then find which one provides the best accuracy. You can also tweak parameters for a particular algorithm to see if it returns a more accurate model. 

scitkit-learn provides functions for all of these algorithms, so it’s straightforward to create the model. 

EVALUATING THE MODEL

You want your model to be the best it can be, so you need to evaluate its performance. Two common variables in evaulating a model are bias and variance. 

Bias is the difference between the model’s predicted value and the correct value. 

Variance is how much the predictions change when different data is used. 

You want to achieve a good balance between bias and variance.

High bias -> underfitting.

Underfitting happens when the model is too simple to account for the noise in training data. This can happen if there is not enough data or not enough features (columns), or too much noise in the data. If a model doesn’t perform well on both the training data and the testing data, it signals underfitting.

High variance -> overfitting.

Overfitting happens if you train a model on one set of data and it performs very well, but if you then present it with new data, it does not perform well at all. This can happen if the model is overly complex and it tries to fit too closely to the training data. The model may predict very well on the training data, but then performs poorly on testing data.

One technique to check the performance of a model is cross-validation.

Cross-validation means training your model several times, using different splits of training/testing data each time. Your dataset is split into several folds, or subsets. Then one fold is held out as the validation or test set, and the remaining folds are used to train it. This is performed several times, so each time the training and test sets change. 

 

sciikit-learn also provides a metrics library so you can easily get performance scores for your models. 

  • accuracy score = correct predictions/total predictions
  • precision = true positives/(true positives + false positives)
  • recall = true positives/(true positives + false negatives)
  • F1 score = (2 x precision x recall)/(precision + recall)
  • specificity = true negative/ (true positives + false negatives)
  • confusion matrix  – shows true positive, true negative, false positive, and false negative counts

By checking metrics from various algorithms, you can choose the best model. 

PREDICTING!

Once you have a model that you are satisfied with, you then want to use it in your app. 

It is common practice to do the preprocessing, creation, and evaluation of your model using Python, in an environment like Jupyter Notebooks. From there, you can export your model as a file.

Then, within your Streamlit app, you can load the model and use it to make predictions. 

In this lesson’s activities, you will go through this entire process using a stroke risk dataset. You will see how to preprocess the data, create models using different algorithms, and then use a model in a simple Streamlit app to predict the risk of stroke, given some input characteristics. 

ACTIVITY 1: TRAIN AN AI MODEL IN JUPYTER NOTEBOOK

Estimated time: 60 minutes

Explore a Stroke Risk Dataset to build an AI model

Follow this video to:
  1. Download a stroke prediction dataset from Kaggle.
  2. Work with the data in a Jupyter Notebook to:
    • Review the data
    • Preprocess the data to prepare it for the model
    • Create some different models
    • Evaluate and choose a model for your app
    • Export the model
Download Notebook

CHALLENGE

Try out a different model than the ones in the Jupyter Notebook. 

  1. Research the scikit-learn website for other classification algorithms, and look at other model-building examples on Kaggle.
  2. Choose one algorithm and add the code to your notebook to create the model.  
  3. Use the scikit-learn metrics to check for accuracy. 

How does your model perform? Is it better than any of other algorithms in the notebook?

ACTIVITY 2: BUILD A PREDICTION APP

Estimated time: 45 minutes

Use your model in a Streamlit App

Follow this video to make a web app that will make a stroke risk prediction based on user input.

CHALLENGE

The Iris dataset is a classic dataset that classifies iris flowers into 3 species (setosa, versicolor, and  virginica) based on the petal and sepal dimensions.

  1. Do some research on the dataset to learn its features and targets. 
  2. You can download the dataset and create your own model or use this model (pickle file) created using K-nearest neighbors. Note that no scaler was needed for this dataset.  The pickle file contains just the model.
  3. Import the model and create a Streamlit app to predict the iris species based on the four dataset features.

TECHNOVATION INSPIRATION

Here are some pretty amazing examples from Technovation participants who used Python and Streamlit to build web apps incorporating machine learning models. 

REFLECTION

You have gone through the entire process of preprocessing a dataset, building several models, and evaluating and choosing one to use in an app.  That is A LOT to learn in one lesson!

reflection
What type of model do you think you will need for your solution - classification or regression?
What parts did you find difficult to understand?
What steps can you take now to learn more so you can build your solution?
Previous slide
Next slide

REVIEW OF KEY TERMS

  • Preprocessing – taking a dataset and making sure the data in it is suitable to train a machine learning model with
  • Classification algorithm – an algorithm used to train a machine learning model that will classify or predict discrete values
  • Regression algorithm – algorithm used to train a machine learning model to predict a value on a continuous range
  • Bias – the difference between the model’s predicted value and the correct value, due to incorrect assumptions that simplify the model
  • Variance – the amount of variability in model predictions, when a model is unable to generalize when faced with new data
  • Overfitting – when the model fits too well to the training data that it cannot predict well on new data, caused by high variance in the model
  • Underfitting – when a model is simplified too much and does not perform well on either training or testing data, caused by high bias or assumptions in the model
  •  

ADDITIONAL RESOURCES

Machine Learning 

Streamlit

girl looking at phone with robot floating above

All About AI

  • Learn the basics of how artificial intelligence works

These are the activities for this lesson:

HOW DOES AI WORK?

Earlier, you learned how artificial intelligence is being used in different areas to make an extraordinary impact on our daily lives. Let’s go a little deeper into what it is and how it works.

True artificial intelligence is not quite here yet. There doesn’t yet exist a system that completely thinks and acts like a human. When we think of AI in our everyday lives, we are really thinking about machine learning. 

When we talk about AI in this curriculum, we’ll really be talking about two subsets of Artificial Intelligence, Machine Learning and Generative AI.

What are they?

face recognition

Machine Learning

is a subset of AI where a machine (computer) "learns" to identify patterns so it can make predictions.

That's how Youtube can predict the next video you might like to watch, or Facebook can identify your face in an image.

generated girl with robot

Generative AI

can generate text, images, and sounds. It uses Large Language Models to be able to create content based on lots and lots of existing data. 

ChatGPT and DALL-E are current popular examples of generative AI.

Let’s dive deeper into Machine Learning.

MACHINE LEARNING HAS THREE MAIN PARTS

DATASET

FINDS PATTERNS WITH LEARNING ALGORITHM


PREDICTION!

Source: “Learning about Artificial Intelligence: A hub of MIT resources for K-12 students”, MIT Media Lab

DATASETS

  • AI needs a LOT of data to learn from.  AI uses a dataset, which is just a very large set of data! In today’s world, computers can access more data than ever before. That’s one reason AI has made such huge advances in the past few years.

AI:

  1. learns from the data
  2. and eventually can find patterns on its own
  3. when it takes in new data
    • it can make a prediction
    • based on the patterns.

STOP AND DISCUSS

Where does AI get its data? Well, it gets a lot from you and me.

In your household, what sorts of data do you create every day through technology?

Did you think of any of these?
  • Every Google search
  • Words you type into emails
  • Every question you ask Alexa/Siri/OK Google
  • Connected devices - each time you turn on lights, turn on air conditioning or heat
  • Taps you make on your cell phone
  • Anything you purchase online
  • Who you are connected to on social media
  • Songs you listen to
  • Steps you take
girls discussing

AN EXAMPLE

Let’s step through how Google Maps uses AI to give you directions to where you want to go. Hover over each box to reveal how Google Maps addresses each part.

DATASET

DATASET

Google Maps takes the following inputs to make a prediction.
  • current location
  • destination
  • mode (walk, car, public transport)
  • traffic

FINDS PATTERNS

FINDS PATTERNS

Google Maps is constantly learning from people who use Google Maps. That data are fed into the learning algorithm so that Google Maps can continue to improve upon its predictions

MAKES PREDICTION

MAKES PREDICTION

Based on its current knowledge, Google Maps predicts the best route for you to take to your destination. It might give you different options. When you choose one, it continues to learn from your choice

STOP AND DISCUSS

Now you try it!

Step through the process with Youtube.

  1. What is the dataset?
  2. How does Youtube learn?
  3. What does it predict?

 

ACTIVITY: AI IN ACTION

Estimated time: 15 minutes

Explore some of the websites below to get a taste of what AI can do.

As you explore, consider:
  • Could you take the concept in front of you and apply it in a different context?
  • What sort of data do you think is needed to make these applications work?
Instrument Playground - based on an image, AI generates what it believes you would hear if you were actually there.
AutoDraw - takes your doodling and predicts what it is you’re trying to draw, very quickly!
X Degrees of separation - takes two art pieces and shows us a bridge of similar artworks that connects the two together.

REFLECTION

Now that you have a glimpse of what it takes to create artificial intelligence, you might want to think about the problem you are solving, and how AI might be useful.

Sunset and reflection over lake
Can you think about your problem and possible solution in terms of the three parts of AI - data, pattern, prediction?
How would you address all three parts in your solution?
Previous slide
Next slide

REVIEW OF KEY TERMS

  • Artificial Intelligence (AI) – machines/programming that can do tasks normally thought to be done only by humans
  • Machine Learning – the subset of AI where a technology is trained with data and “learns” to recognize patterns in order to make predictions
  • Generative AI – technology that has the ability to create content like text, images, and and sound
  • Large Language Model – an AI model that predicts and generates text, trained using enormous amounts of data
  • Datasets – information that is used to teach AI to recognize patterns and predict something
  •  

ADDITIONAL RESOURCES

Want to explore some more cool AI?

girl with headphones working at desktop computer

Find Patterns with AI

  • Train a machine learning model to predict something

These are the activities for this lesson:

3 PARTS OF MACHINE LEARNING

Recall that Articifical Intelligence, specifically Machine Learning, has 3 main parts.

Dataset

Find Patterns

Make Prediction

In this lesson, we’re going to focus on the second part, Find Patterns, by training our own AI model that will be able to make a prediction.

There are many free online platforms where you can train an AI model, using supervised learning. 

Supervised learning is just as it sounds – you supervise how the model learns by telling it the correct answer.

For example, say you want an AI model to tell if a picture is a dog or a cat.

dog's face
cat's face

Your dataset will be lots and lots of pictures of dogs and cats.

You will help train the model by telling it which pictures are dogs and which are cats

PLANNING FOR YOUR MODEL

Your model will predict, or classify something. Often these models are called classification models, for that reason. 

First steps:

  1. What you are classifying? Are they images, text, sounds? This is your data type.
  2. What are the different possible classifications?  For example, dogs and cats. These are your classes. They are also sometimes referred to as labels.
  3. Gather the appropriate data to train your model. Find lots and lots of varied data to represent each class. For example, lots and lots of pictures of different types of dogs and cats!
Teachable Machine screenshot training dogs and cats

RECOMMENDED PLATFORMS

There are many free and open source platforms available to create AI classification models. 

We have curated a list of programs and platforms where you can:

  • build your model to make a prediction
  • then use your model in a mobile or web app to perform an action based on the prediction

Here is a quick overview of what each platform can classify and integrate with.

Platform Classification Types Technovation Integration
Teachable Machine by Google images, sounds, poses App Inventor, Python, other integrations possible
MachineLearningForKids images, sounds, text, numbers Python, App Inventor
MIT App Inventor images, sounds, poses App Inventor
Ximilar images Thunkable, App Inventor, wep apps, using APIs

ACTIVITY: TRAIN A MACHINE LEARNING MODEL

Estimated time: 30 minutes

Build a Rock, Paper Scissors model

Follow the worksheet to use Google's Teachable Machine platform to build a machine learning model to recognize hand signs of rock, paper and scissors.

Then see your model in action with a simple pre-built javascript interaction.
Open worksheet

REFLECTION

You’ve made your first AI model! This should give you a glimpse into the process for making an AI model. All the model creation platforms work in a similar way, although the interfaces may differ slightly.

reflection in building
Was your model successful in detecting rock, paper or scissors?
Was it made with a "good" dataset?
How could you make the dataset better?
If a friend or person in a different location from you used your model and project, would it perform as well? Why or why not?
Previous slide
Next slide

REVIEW OF KEY TERMS

  • AI (or machine learning) Model – artificial intelligence that is trained on a dataset to recognize patterns to predict or classify something
  • Supervised Learning – machine learning where a model is trained by telling it correct or incorrect result
  • Class – a label that is provided to an AI model so it learns how to classify inputs by its class

ADDITIONAL RESOURCES

If you want to learn more about artificial intelligence and machine learning, here is a great playlist from Daniel Schiffman of New York University