May 12, 2025

Find Patterns with AI (Training a Model)

0

Muliyo mutya, team! Greetings from KAWA! It’s a great time to explore something really cutting-edge: Artificial Intelligence (AI) and specifically, how we can teach computers to find patterns, just like humans do, but much faster!

You’ve learned how to make apps respond with conditionals. Now, imagine making your app recognize things – like pictures, sounds, or even poses! That’s where AI, particularly Machine Learning (ML), comes in.

Lesson Topic: Find Patterns with AI (Training a Model)

Part 1: How Does AI Learn? (Think Like a Teacher!)

Remember the basic steps of Machine Learning we touched upon?

  1. Dataset: Gathering the information (like pictures or sounds).
  2. Find Patterns: The AI learns from the data (This is our focus today!).
  3. Make Prediction: The AI uses what it learned to make a guess about new data.

Today, we’re diving into Step 2: Finding Patterns. This is often called Training the AI Model.

One common way AI learns is through Supervised Learning. It’s just like teaching someone!

  • Ugandan Analogy: Imagine teaching a young child the difference between a ripe yellow banana (ndiizi) and a green one (bogoya) meant for cooking. You show them many examples: “Look, this yellow one is ndiizi, it’s sweet.” “This big green one is bogoya, we cook it.” You supervise their learning by giving them examples with the correct labels (ndiizi or bogoya).
  • Lesson Example: If you want AI to tell apart dogs and cats in photos, you feed it thousands of pictures, clearly labeling each one: “This is a dog,” “This is a cat.”

The AI analyzes all these labeled examples and starts figuring out the patterns itself – what features usually mean “dog” (floppy ears? snout shape?) and what features mean “cat” (pointy ears? whiskers?).

Part 2: Planning Your AI’s Education

When you train an AI model to put things into categories like this (dog/cat, ndiizi/bogoya, rock/paper/scissors), it’s called a Classification Model.

Before you start training, you need a plan:

  1. What kind of data are you classifying? This is your Data Type.
    • Images: Photos of crops, different types of waste, skin conditions?
    • Sounds: Recordings of bird calls, different cough sounds, simple voice commands in Luganda or Lusoga?
    • Poses: Body positions for exercises or sign language?
    • Text: Customer feedback (positive/negative), news headlines (sports/politics)?
  2. What are the categories you want the AI to learn? These are your Classes (also called Labels).
    • Examples: Healthy Plant, Diseased Plant; Plastic, Organic, Paper; Rock, Paper, Scissors. You need at least two classes.
  3. Gather Your Teaching Materials (Dataset): This is CRUCIAL! You need lots of examples for each class. And the examples need variety.
    • Example: For a “Healthy Maize Leaf” vs. “Diseased Maize Leaf” classifier, you need many photos of healthy leaves (different angles, lighting, maize varieties) AND many photos of diseased leaves (different diseases, stages of disease, angles, lighting). If your data isn’t good or varied enough, your AI won’t learn well!

Part 3: Tools for Teaching AI (Platforms)

The great news is you don’t need to be a top AI scientist to train a simple model! There are free, easy-to-use online platforms. Here are some recommended for Technovation:

PlatformClassification TypesTechnovation Integration
Teachable Machine (Google)Images, Sounds, PosesApp Inventor, Python, other integrations possible
MachineLearningForKidsImages, Sounds, Text, NumbersPython, App Inventor
MIT App InventorImages, Sounds, PosesApp Inventor (using built-in extensions)
XimilarImagesThunkable, App Inventor, Web apps (using APIs)

Export to Sheets

Today, we’ll focus on Google’s Teachable Machine. It’s very user-friendly, great for visual things (images, poses) and sounds, and you can potentially link models you build there to App Inventor!

Part 4: Let’s Train! Rock, Paper, Scissors AI (Activity – 30 mins)

Time to become AI trainers! We’ll teach the computer to recognize the classic hand game: Rock, Paper, Scissors.

Your Goal: Use your webcam to train a Teachable Machine model to classify pictures of your hand showing Rock, Paper, or Scissors.

Tool: Google’s Teachable Machine website.

Steps (Follow the Worksheet for details):

  1. Go to Teachable Machine: Open the website (link in your worksheet).
  2. Start a Project: Choose an “Image Project”.
  3. Define Your Classes: You need three categories. Name them clearly:
    • Class 1: Rock
    • Class 2: Paper
    • Class 3: Scissors
  4. Gather Data (The Teaching Part!): For each class, use the “Webcam” button to record many examples.
    • For Rock: Make a fist. Record pictures showing it from slightly different angles, maybe closer or further, different lighting if possible. Try your other hand too. Aim for 50-100+ images if you can! More data is often better.
    • For Paper: Show your open flat hand. Again, capture variety – different angles, positions, lighting.
    • For Scissors: Show your two-finger ‘V’ sign. Capture lots of varied examples.
  5. Train the Model: Once you have plenty of images for all classes, click the “Train Model” button. Be patient, it might take a minute or two. This is where the AI analyzes your pictures and learns the patterns!
  6. Test Your AI! After training, use the “Preview” section. Hold up your hand showing Rock, Paper, or Scissors to the webcam. Does the model correctly predict which class it is? Look at the confidence scores – how sure is the AI? Try different angles and distances.
  7. Worksheet: Complete any other steps outlined in your worksheet.

Part 5: How Did Your AI Do? (Reflection)

Congratulations, you’ve trained an AI! Now, let’s think critically about it:

  • Was your model successful? How well did it recognize Rock, Paper, and Scissors in the preview? Did it get confused sometimes? When?
  • Was your dataset “good”? Did you provide enough pictures for each class? Was there enough variety (angles, lighting, maybe different backgrounds)? Or did you mostly take pictures of your hand in the exact same way?
  • How could you make the dataset better? What could you add or change in your training images to make the AI more accurate? (Maybe pictures from teammates? Pictures in different rooms?)
  • Generalization: Imagine your friend in Kampala tries using the model you trained using their webcam. Would it work as well? Why or why not? (Think: Your model mainly learned your hand, your skin tone, your room’s lighting. It might not generalize perfectly to different conditions – this relates to bias in AI).

Part 6: Quick Review (Key Terms)

  • AI (or machine learning) Model: The ‘brain’ you train with data to recognize patterns and make predictions/classifications.
  • Supervised Learning: Training an AI by giving it examples with the correct answers (labels/classes).
  • Class: A category or label you want the AI to classify things into (e.g., ‘Rock’, ‘Paper’, ‘Scissors’).

Part 7: Want to Learn More?

AI is a huge field! If this sparked your interest, the lesson recommends a great video playlist by Daniel Schiffman that explains AI and Machine Learning concepts further.

Conclusion

Webale nnyo for training your first AI model! This technology might seem complex, but tools like Teachable Machine make it accessible for you to start experimenting. Think about how classifying images or sounds could be part of your Technovation app to solve a real problem here in Uganda – maybe identifying pests on crops, sorting recyclables, or even understanding simple voice commands.

The quality of your data is key to making AI work well. Remember: Variety, Variety, Variety!

Keep exploring, keep innovating! Musibye bulungi! (Stay well!)

Leave a Reply

Your email address will not be published. Required fields are marked *