Skip Navigation

Anti-Cyberbullying Assistant

By Bilal Qadar and Nima Boscarino 60-90 minutes
Grades 4-6
Science and Technology,
Social Sciences,
  • Programming
  • Data
  • Technology and Society
  • Design
Tools & Languages
Machine Learning for Kids,

Key Coding Concepts

  • Algorithms
  • Conditional Statements


Artificial Intelligence 

Ability of a machine or computer program to think and make decisions.


Machine Learning

Machine learning algorithms are algorithms with the ability to automatically learn and improve from experience without being explicitly programmed.



Pieces of information usually formatted in a specific way (e.g. numbers, pictures, and words)

In this lesson, learners will create an AI-powered assistant that will help them identify cyberbullying.

This is a Canada Learning Code Week lesson plan! Once you’ve taught at least one of our lesson plans, share your impact with us:

Technology (per learner):

  • Laptop

Before the lesson...


Programming usually involves writing out clear and unambiguous instructions for a computer to follow, in order to solve a problem or complete a task. For some complicated tasks, however, computer scientists have developed “machine learning” algorithms that can discover patterns by analyzing huge amounts of data.

Machine learning is present in many technologies in today’s world! Many people may be familiar with voice assistants in our devices, like Siri and Alexa. Machine learning is often used for applications where developers want to replicate human actions, such as playing a video game, finding routes on a map, understanding text, and more!

Like humans, these kinds of systems learn through experience and practice. They train on data to improve and we can retrain them as necessary. For example, we might retrain the system once we get access to new data. A trained machine learning algorithm is called a model.

(OPTIONAL) Let’s Go on a Picnic

To introduce your learners to the way the machine learning algorithms work, have them simulate the data-collection and model training process by repeatedly guessing which items are allowed on a picnic. The instructions for the activity can be found in the solution sheet.


Say: “In this lesson, we’ll be building a machine learning model that will help us identify cyberbullying.”

Do: Read The “Social Butterfly” Effect together and follow the prompts at the end of the story.”

Do: Use the solution sheet to guide learners through the following steps:

  • Adding Data and Training
    • Creating a new project
    • Adding training labels
    • Adding the comic book data
    • Training and testing the Machine Learning model
  • Creating the assistant in Scratch 3.0
    • Setting up the project
    • Deleting and adding a sprite
    • Resizing characters
    • Asking a question
    • Recognizing Nice and Mean phrases
      Turn that frown upside down!


Do: Use this worksheet and have learners Think-Pair-Share the following questions:

What are/is:

  • 3 new things that you learned today
  • 2 areas that challenged you in this lesson
  • 1 way you can use something from this lesson in your own life

Learning Outcomes

I can find patterns in data
I can train an algorithm using supervised learning
I can use conditional statements to control what happens in my project
I can use machine learning to tackle cyberbullying

Assessment Ideas

Encourage learners to tinker with their models to verify that mean and nice phrases are appropriately categorized. If some phrases are miscategorized, learners may need to add to their training data and retrain their models.

Have learners demonstrate an understanding of the parts of a machine learning project, including:

  • Data collection
  • Training and testing a model
  • Using the model in an appropriate application (e.g. a scratch Scratch project)

Have learners self-assess their learning using the single-point rubric in the reflection worksheet.

Complete the add-ons in the solution sheet (e.g. happy spin and bounce).

For advanced learners, you can challenge them to make the Scratch logic a bit more complicated, especially if the learners have prior Scratch experience. As a couple of examples:

  • The Anti-Cyberbullying assistant could be extended to suggest nice phrases if someone enters a mean phrase.
  • The Anti-Cyberbullying assistant could display the confidence level of its classification. This is a measure of how sure it is that a phrase is mean or nice. (Hint: There’s a special block for this!)
  • If the assistant isn’t very confident in the classification of a phrase (e.g. less that 20%), it could ask the user to select which label it should be classified as, add that new phrase to the training data, and retrain the model. (Hint: There are blocks for this, too!)

Machine Learning for Kids

The “Social Butterfly” Effect

In Praise of Think-Pair-Share (Cult of Pedagogy)

Teach lessons that are tied to your existing curriculum!


More Lesson Plans For Grades 4-6

    View All Lesson Plans

    Explore lessons based on components

    The K-12 Computer Science Framework

    Although learning how to build digital projects is a key part of Computer Science education, students should also learn a wider set of skills and competencies that will help them to harness the power of digital technologies as both creators and consumers. A comprehensive approach to K-12 Computer Science education includes learning about the following five focus areas:

    View Framework ➝


    By the end of high school, students should be able to create a simple computer program.

    Computing and Networks

    By the end of high school, students should understand and be able to use the tools and devices commonly used to build digital projects.


    By the end of high school, students should be able to explain how we use computers to create, store, organize, and analyze data.

    Technology and Society

    By the end of high school, students should be able to explore the ways in which technology and society have mutually shaped each other.


    By the end of high school, students should be able to apply design principles to the digital projects they create.