Software decides things for you all day: what appears at the top of a feed, whether a photo has your face in it, what word you meant when you mistyped. The part of a program that decides is called an AI model.
Today you meet the main kinds, then you build one yourself in Scratch: a guesser made of rules that tells a cat from a dog. It works on the easy cases and falls apart on the awkward ones, and that is exactly the problem you solve next lesson.
Keep this to four minutes. Take two or three examples from the class rather than supplying your own, so the lesson starts from what they actually use.
Teams compete. Five real things software does are revealed one at a time. For each one, call out the kind of model behind it.
The answers: 1 is a recommendation system, 2 and 3 are generative models, 4 is a classifier, and 5 is an agent: it is given a goal, then plans, uses tools and acts in a loop.
Reveal one at a time and take the call before you show the answer, or it collapses into reading. Item 5 is the one they will argue about, and that argument is the lesson.
| Kind | What it does | Where you meet it when coding |
|---|---|---|
| Generative | Produces something new: text, an image, code | An assistant that drafts a function or explains code |
| Recommendation | Ranks options for one person | What a shop or a feed shows a given user |
| Classifier | Sorts an input into categories | Cat or dog, spam or not, rock or paper |
| Agent | Takes a goal, plans, uses tools, acts in a loop | Software that carries out a multi-step task |
The one you are about to build is a classifier. It takes something in and puts a label on it, and it is the simplest of the four to build by hand.
Five minutes maximum. The table is a reference they come back to in Lessons 32 and 33, not the teaching.
Go to scratch.mit.edu and click Create to start a new project. Call it Cat or Dog.
You will write all of today's code on the cat sprite that is already there, so you do not need to add anything.
Anyone signed out can still build and run; they just cannot save to the site. Have them save the class way instead.
Your guesser asks yes-or-no questions. The player presses y for yes or n for no.
Build this from Events (gold), Looks (purple), Control (gold) and Sensing (light blue). The wait until block holds the script until a key goes down.
Read it and predict: if you answer n, what will the cat do?
when green flag clicked
say [Think of a pet: a cat or a dog. Answer with y or n.] for (3) seconds
say [Rule 1. Does it bark?]
wait until <<key [y v] pressed?> or <key [n v] pressed?>>
if <key [y v] pressed?> then
say [I think it is a DOG.] for (4) seconds
stop [this script]
end
Predict first, before anyone clicks the green flag. The answer is that it does nothing at all and simply ends, because there is no rule for n yet. Students who expected CAT have just discovered that a rule only covers what it was written to cover, which is the whole lesson in one line.
You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.