Machine Learning with PictoBlox
Algorithms and ProgrammingArtificial IntelligenceDigital LiteracyComputing SystemsImpact of Computing

Machine Learning with PictoBlox

Grades 6–12
1 hr 20 min
6 steps
CSTASTELISTEGrade 9 through Grade 12+3

Standards Alignment

CSTA

  • 3A-DA-12: Create computational models that represent the relationships among different elements of data collected from a phenomenon or process.
  • 3A-AP-13: Create prototypes that use algorithms to solve computational problems by leveraging prior student knowledge and personal interests.
  • 3A-AP-15: Justify the selection of specific control structures when tradeoffs involve implementation, readability, and program performance, and explain the benefits and drawbacks of choices made.
  • 3A-AP-21: Evaluate and refine computational artifacts to make them more usable and accessible.
  • 2-DA-09: Refine computational models based on the data they have generated.

STEL

  • 6-8-2S: Defend decisions related to a design problem.
  • 6-8-6C: Compare various technologies and how they have contributed to human progress.
  • 6-8-6D: Engage in a research and development process to simulate how inventions and innovations have evolved through systematic tests and refinements.
  • 6-8-7Q: Apply the technology and engineering design process.
  • 6-8-7R: Refine design solutions to address criteria and constraints.
  • 6-8-7V: Improve essential skills necessary to successfully design.
  • 9-12-5H: Evaluate a technological innovation that arose from a specific society’s unique need or want.

Related NC CTE courses

  • Drafting Engineering (DREN)
  • PLTW Engineering (PLWE)
  • SREB Aerospace Engineering (AEEN)
  • SREB Clean Energy Technology (CENT)
  • SREB Energy and Power (ENPO)
  • SREB Innovations in Science and Technology (INST)
  • Technology Engineering and Design (TEND)

Showing 12 of 32 standards.

Lesson Steps

1

🤖What is Machine Learning?

10 min

Overview

This project covers the fundamentals of machine learning, a branch of artificial intelligence that uses data and algorithms to train a machine to imitate intelligent human behavior.

Below is a list of just a few ways humans use machine learning. Can you think of any more?

  • Facial recognition
  • Social media monitoring
  • Marketing and advertisement
  • Self-driving cars
  • Reading handwriting from phones
  • Virtual assistants (Siri, Alexa, etc)
  • Customer service chatbots
  • Planning out the fastest route to a destination
  • New song recommendations
  • Farmers checking out and diagnosing problems with crops
  • Clinical decision support and robotic assistance for medical procedures 

How Does It Work?

Check out the video below to see an example of Google's machine learning platform, Teachable Machine!

Let’s highlight the basic steps of machine learning.

  • Collecting Data – Machines learn from the data you give them. The quality of data you feed the machine will determine the accuracy. What could be a good source of data for training AI?
  • Preparing the Data – You can do this by removing unwanted data, randomizing the data so the ordering does not affect the learning process, visualizing it so you better understand how the data is structured and being represented, and splitting the data between a training set and a testing set. The training set uses the samples your model learns from. The testing set is used to check the accuracy of your training model.
  • Choosing a Model – This determines the output you get after running the training data. Scientists and engineers have developed various models suited for different tasks like speech recognition, image recognition, prediction, etc.
  • Training the Model – This is when you pass the prepared data to your machine learning model to find patterns and make predictions. With more training and more data, the model gets better at predicting.
  • Evaluating the Model – Test the performance of the model with entirely new, unseen data.
  • Parameter Tuning – Parameters are the variables (changes) in the model that the programmer decides. Tuning the parameter’s values may increase the accuracy.
  • Making Predictions – Apply your model to new data to predict the likelihood of a particular outcome. How accurate would the machine learning app you used be on data from your photos?

What's Next?

In the following lessons, you will learn to implement machine learning steps in an open-source (free) software called PictoBlox. Happy learning!

Teaching tips

For this project, students will be using their devices and will need permission to enable the following:

  • Microphone
  • Camera
  • Uploading images

The following domains may need to be whitelisted by your school's IT department (or parental controls if at home):

  • https://ml-edu-activity.appspot.com
  • https://thestempedia.com
  • https://teachablemachine.withgoogle.com
  • https://vimeo.com
  • https://descript.com
2

💻Downloading the Software

5 min

Getting Started!

To get started, you must first download the PictoBlox Software on your device. Don’t worry, it’s free! Just make sure you choose the right device. Click this link to download the software!

A window will pop up. Skip the name and email fields and click the "No thanks, I just want to download PictoBlox" button to proceed.

Once the files are downloaded to your device, you should find the following icon in your library:

This lesson series will focus only on machine learning applications. However, we encourage you to explore the STEMpedia site and find more educational content.
As an alternative, you can also visit Google’s Teachable Machine in your browser, which uses the same machine learning concepts, without having to download software. Visit this link to begin! https://teachablemachine.withgoogle.com

3

🤟Hand Pose Classifier

10 min

GETTING STARTED WITH THE HAND POSE CLASSIFIER

 

Play this video to learn more!

 

The Hand Pose Classifier is used for classifying different hand gestures into different classes. A class is like a label or category where you would put all of your similar images. 

The model works by analyzing the position of your hand with the help of 21 data points. We’ll look at this in detail in the video or written tutorial.


STEPS

 

Setting up the Environment

  1. We begin by making the machine learning model in Pictoblox. When you open the software, select the “Machine Learning Environment” option.
  2. Click on “Create a New Project.”
  3. Type in a project name of your choice and select the “Hand Pose Classifier” extension. You can be as specific as you want for a project name, but it is usually a good idea to include the date and the general idea you are working on. For example, if I want to teach the machine American Sign Language, then I might put “12/9/2022 ASL symbols.“
  4. Click the “Create Project” button at the bottom right corner to open the window.
  5. Inside this workflow, there are two classes already made for you. Change the class’ names before you start making it, or you won’t be able to change it later.

Collecting and Uploading the Data

  1. Upload your data to your class by uploading your own pictures or using the webcam (recommended). When using the webcam, click on the “Hold to Record” button to capture the pic.
  2. Start with 30+ pictures of each class. The more data, the better results! Try out different angles, proximity to the webcam, lighting, etc...

 

Training the Model

  • By training the model, we extract meaningful information from the images (the 21 data points), and that in turn updates the weights. A weight is a parameter that decides how much influence the input will have on the output. 
  • When you click the “Advanced” tab, you will see three hyper parameters. 
    • Epochs– The total number of times your data will be fed through the training model. Therefore, in 10 epochs, the dataset will be fed through the training model 10 times. Increasing the number of epochs can often lead to better performance.
    • Batch Size– The size of the set of samples that will be used in one step. For example, if you have 160 data samples in your dataset, and you have a batch size of 16, each epoch will be completed in 160/16=10 steps. You’ll rarely need to alter this hyperparameter.
    • Learning Rate– It dictates the speed at which your model updates the weights after iterating through a step. Even small changes in this parameter can have a huge impact on the model performance. The usual range lies between 0.001 and 0.0001.
  • Click on the “Train Model” button to start training. The higher the reading in the accuracy graph, the better the model. If the model accuracy is bad or below “moderate,” then try increasing the epochs or adding more samples. The range of the accuracy is 0 to 1.

 

Testing the Model

Now that the model is trained, let us see if it delivers the expected results. We can test the model by either using the webcam again or by uploading a new image. The model will start predicting based on the image in the window. 

 


REFLECTIONS

  • Do you think the data would work better if there were more than 21 hand points for each sample? 
  • What system would benefit from trained hand gestures?
  • What could you do to improve your own model?
4

🔊Audio Classifier

15 min

SPEECH RECOGNITION

 

Play this video to learn more!

This Audio Classifier is used for classifying sounds and speech data. This type of machine learning can be applied to many practical scenarios, like classifying music clips to identify music genre or having devices that understand your voice commands. 

If you have already completed the Hand Pose Classifier, then this should be easy for you because you have already received an introduction to using PictoBlox. The tutorial steps, as seen in the above video, are the following:


STEPS

Setting up the Environment

  1. We begin by making the machine learning model in Pictoblox. When you open the software, select the “Machine Learning Environment” option.

  2. Click on “Create a New Project.”
  3. Type in a project name of your choice and select the “Audio Classifier” extension. You can be as specific as you want for a project name, but it is usually a good idea to include the date and the general idea you are working on. For example, if I want to teach the machine to distinguish between different bird species, then I might put “12/10/2022 bird calls.”
  4. Click the “Create Project” button at the bottom right corner to open the window.
  5. Inside this workflow, there are two classes already made for you. Change the class’ names before you start making it, or you won’t be able to change it later.

Collecting and Uploading the Data

  1. You should see two classes to begin, with the first being “BackNoise.” This class includes all sounds related to background noise and that will have no meaning. Try this yourself with the background noise of A/C, fan, TV, moving around, light music, and anything else you can think of.
  2. Then, name your next class. Remember similar audio is put in one class. If you were doing farm animals, a class might be “owl” or “mallard.” 
  3. Now, you can add samples by using your device’s microphone. Click on the “Microphone” button to record samples. Samples are recorded in a 1-second burst. This might take some trial and error, so make sure you delete samples that don’t have the right sound. 
  4. Add at least 20 samples to each class.

Training the Model

  1. By training the model, the computer extracts meaningful information and patterns from the new, unheard sounds.
  2. When you click the “Advanced” tab, you will see three hyper parameters. 
  • Epochs– The total number of times your data will be fed through the training model. Therefore, in 25 epochs, the dataset will be fed through the training model 25 times. Increasing the number of epochs can often lead to better performance.
  • Batch Size– The size of the set of samples that will be used in one step. For example, if you have 160 data samples in your dataset, and you have a batch size of 16, each epoch will be completed in 160 / 16 = 10 steps. You’ll rarely need to alter this hyperparameter.
  • Learning Rate– It dictates the speed at which your model updates the weights after iterating through a step. Even small changes in this parameter can have a huge impact on the model performance. The usual range lies between 0.001 and 0.0001.

3. Click on the “Train Model” button to start training. The higher the reading in the accuracy graph, the better the model. If the model accuracy is bad or below “moderate,” then try increasing the epochs or adding more samples. The range of the accuracy is 0 to 1.

 

 

Testing the Model

Now that the model is trained, let us see if it delivers the expected results. We can test the model using the microphone again. The model will start predicting based on the new audio you produce. 

 

 

This achievement is music to our ears!


REFLECTIONS

  • Can you think of some examples of applications of audio classification using machine learning?

  • What are some challenges that we might encounter when building a machine learning model for audio classification?

  • How do we go from machine learning for audio classification to actually executing commands? If you want to try this yourself using python code, go to the next step!

 

5

🧑🏽‍💻Executing Commands with Sound Recognition

20 min

Play the video to learn more!

 

Set Up the Environment

In this tutorial, we will use voice commands to control a sprite’s actions. A sprite is a two-dimensional visual icon used in computer graphics. They are typically used for characters or other moving objects in video games.  

The steps to complete this project are similar to the last section, but with a few more steps in block coding. They are as follows:

 

  • Choose what you want to do with your sprites, as a general idea. In my example, I will be choosing sprites of different bird species.

  • To choose your sprite, open up the “Block Coding” environment after you open up PictoBlox. At the bottom right corner, look through different sprite options and choose. In the video, I also show you how you can upload your own unique sprite from pictures on the Internet.

 

  • You may even see the different pre-set costumes attached to each sprite. If you are into graphic or video game design, this would be a good activity to diversify your characters.

 

  • Under file at the top left,choose “new” and save your project with a specific name, as you will come back to it later.
  • Open up the Machine Learning (ML) Environment. This is where we will create the audio data to command different abilities for the sprite, like jump, walk, switch costumes, spin, speak, and whatever else you can think of. In my case, I will name a different bird species for each class and attach sounds corresponding to that bird.
  • Now, train and test your model with enough samples for each class, just like we did in the previous section.
  • Once you are done, choose “Export Model” to the top right of the Testing Box. This will upload the ML to the Block Coding environment.
  • Now you can open the correct file and sprite you were working on before.

Write the Script in Block Coding

 

We will be making a script that uses our model to analyze the audio samples we made using our device’s microphone. Once that’s done, our sprite will follow the commands we have programmed. 

  • First, add a when flag clicked block from the Events palette.
  • Follow it up with an open recognition window block from the Machine Learning palette.

  • Now drag a when ( ) is predicted block from the Machine Learning palette. Select the class as BackNoise.
  • Under the block, add what you want your sprite to do. Below we have made examples of different block commands or play around with it yourself!

 

  • Finally, click on the green flag above your sprite to test the script.

 

 

You're soaring to new heights!

6

🔍Object Detection

20 min

Play the video to learn more!

We finally reached object detection! Watch the video or follow the simple steps below.

  • When you open up PictoBlox, choose the Block Coding environment. 
  • At the bottom left, add an extension and find “Object Detection". This will add a new palette, or set up blocks to manage.
  • Find and drag these blocks in the correct order.

  • Click the green flag above the stage, turn on your camera, and have fun!

AI-MAZING JOB!


REFLECTIONS

  • How should AI object detection systems be designed to minimize the potential for biased outcomes?
  • Is it ethical to use AI object detection systems for surveillance purposes, and if so, under what circumstances?
  • What are the potential consequences of AI object detection systems making mistakes, and how can these be minimized?

Materials

  • Computer, Chromebook, or tablet with camera and microphone — 1 per student

Ready to bring this lesson to your classroom?

Sign up to save this lesson, order supplies, and track student progress.