computer4kids is now ComputerLeap. Same free lessons, same team. Read why we changed our name

← All lessons · 🧑‍💻 Coding Academy

⚠️

🎓

⏱ 25 min

Free

When AI Is Wrong

Biased examples and missing data create confident mistakes. Find them and fix them.

🎯 What you will learn

  • Bias starts with the examples
  • Models answer even when they should not
  • Checking results and sources protects people

👋 Let’s get started!

Every example a model learns from teaches it something. If the examples are missing a group or a case, the model cannot know about it, but it may still answer confidently. Let’s see this happen! ⚠️

🪜 Step by step

1. 📚 Biased examples

If every example is a dog, the classifier will call everything a dog.

examples = [(1, "dog"), (2, "dog"), (3, "dog")]
2. 🤖 Confident mistakes

The model still gives an answer, even when it has no good example.

print(guess(50))
3. ✅ Check and fix

Add more and better examples, and check results against trusted sources.

examples.append((40, "cat"))

🧪 Try it!

Change the code and press ▶ Run to see what happens. You can’t break anything!

Only dogs

examples = [(1, "dog"), (2, "dog"), (3, "dog")]
def guess(value):
    best_gap = 100
    best_label = None
    for number, label in examples:
        gap = abs(number - value)
        if gap < best_gap:
            best_gap = gap
            best_label = label
    return best_label
print("Guess for 50:", guess(50))
examples.append((40, "cat"))
print("After one more example:", guess(50))

🎨 Unplugged activity

⚠️ Try an AI tool with a question about your own school or town. Check its answer with two trusted sources. Write down one thing it got right and one thing it got wrong.

Find the missing data

examples = [(1, "dog"), (2, "dog")]
print("Trained on:", set(label for _, label in examples))

📖 Key words

Tap a card to flip it over!

Bias
Unfair patterns from the data ⚖️
Hallucination
Confident but wrong output 👻
Source
Where information comes from 📰

🏆 Challenge

Add an example (50, “bird”) to the list, then print guess(48). Press ▶ Run.

Challenge

examples = [(1, "dog"), (2, "dog")]
def guess(value):
    best_gap = 100
    best_label = None
    for number, label in examples:
        gap = abs(number - value)
        if gap < best_gap:
            best_gap = gap
            best_label = label
    return best_label

Knowledge Check Quiz

  1. Where does a model’s bias come from?
  2. Why can a wrong AI answer still sound sure?
  3. What should you do with an AI answer?
← Previous lesson
Next lesson →