Before you start. You need Python for these lessons. Ask a grown-up to help you install it from python.org, which comes with a simple editor called IDLE. Do not make accounts or type your name into any website to run code.
These lessons use plain Python that you type in yourself. Every program on this page has been run and checked.
Your lessons
Open a lesson. Tick the boxes as you go. Do one lesson at a time.
Lesson 1: How Models PredictAbout 45 minutes
- Get ready
- Do it
- Check yourself
- Show a grown-up
Get ready
You need:
- Python and IDLE (or another editor you already use)
- Paper
Do it, step by step
# Each pet: [height in cm, weight in kg, what it is] pets = [ [25, 4, "cat"], [23, 3, "cat"], [28, 5, "cat"], [30, 6, "cat"], [45, 18, "dog"], [55, 25, "dog"], [38, 9, "dog"], [60, 30, "dog"], ] def predict(weight): if weight < 8: # our dividing line return "cat" return "dog" wrong = 0 for height, weight, label in pets: guess = predict(weight) print(label, "-> machine says", guess) if guess != label: wrong = wrong + 1 print("Wrong guesses:", wrong)You should see something like:
cat -> machine says cat cat -> machine says cat cat -> machine says cat cat -> machine says cat dog -> machine says dog dog -> machine says dog dog -> machine says dog dog -> machine says dog Wrong guesses: 0
Real AI test (with a grown-up): Ask it to explain your model
Optional, and a grown-up runs it. Under 13, the grown-up types and reads, and you direct and check. Read the real-AI guide first. About 20 minutes.
Why we do this. You wrote a dividing line. See whether an AI explains it correctly. You are the expert, so check it.
Prompt 1: Explain features and labels
Here is a dataset of pets as [height in cm, weight in kg, label]: [25,4,cat], [23,3,cat], [28,5,cat], [30,6,cat], [45,18,dog], [55,25,dog], [38,9,dog], [60,30,dog]. A program says “cat” if the weight is below 10, and “dog” otherwise. Which pets does it get wrong? Explain what the features, the label and the prediction are.
Change only made-up parts in [brackets]. Never add a name, school, address, photo or anything private.
What to look for
- You found that a 9 kg dog is wrong when the line is 10. Did it find the same pet?
- Are its definitions of feature, label and prediction right?
- Did it make any mistake? If so, what was it?
Write it down
Tool, prompt, what it said, what you checked, and whether it was right, wrong or not sure. Record sheet
Think about it. Why do you still need to check an AI’s explanation, even when it sounds right?
Check yourself
What are the features, label and prediction in this lesson?
Open the answer
Features: height and weight. Label: cat or dog. Prediction: the guess the program makes.
Which pet is wrong when the line is 10?
Open the answer
The 9 kg dog (38 cm tall). It falls below the line, so the program says cat.
Show a grown-up
Explain to a grown-up what the dividing line does and why moving it changes the answers.
Lesson 2: Build and Train a ClassifierAbout 50 minutes
Ask a grown-up to upgrade to unlock Lessons 2 to 7.
Lesson 3: Training, Testing and Over-fittingAbout 50 minutes
Ask a grown-up to upgrade to unlock Lessons 2 to 7.
Lesson 4: Bias in Data and DecisionsAbout 50 minutes
Ask a grown-up to upgrade to unlock Lessons 2 to 7.
Lesson 5: Language Models and Made-up AnswersAbout 55 minutes
Ask a grown-up to upgrade to unlock Lessons 2 to 7.
Lesson 6: Ethics, Privacy, Copyright and My AI CodeAbout 55 minutes
Ask a grown-up to upgrade to unlock Lessons 2 to 7.
Lesson 7: AI, Society and RulesAbout 50 minutes
Ask a grown-up to upgrade to unlock Lessons 2 to 7.
