This is Lesson 1 of 8 from AI For Youth: Grade 9, shown exactly as subscribers see it. No account is needed to read it. Subscribers get every lesson, the graded quizzes, the project, progress tracking, and a certificate of completion.
Get accessYour child already lives in a world full of AI, and that will be true for the rest of their life. The good news is that understanding it is well within reach. This course explains how AI really works at your child’s grade level, one clear lesson at a time, so they can use it with confidence and know when to double-check it. The first lesson is below. Read it together and see if it fits.
This lesson introduces the two ways of making a computer carry out a task: writing the rules by hand, or collecting examples and letting a procedure find the pattern. It covers what each approach requires, what the word “learning” does and does not mean, the three things every learning procedure needs, and how to decide which approach a given problem calls for.
By the end of this lesson you can
- Explain the difference between a program that follows rules and a model that learned from examples.
- Name the three things any learning procedure needs.
- Decide whether a given problem calls for a written rule or a learned model, and defend the choice.
- Say what a model has not understood, even when its answer is right.
Programs that follow written rules
A rule-based program is a set of instructions written by a person. The computer follows the instructions exactly, and the output is correct whenever the instructions are correct and complete.
Rule-based programming is the ordinary way of making a computer do something. For many tasks it is the right way, and Section 4 lists several. The difficulty appears with tasks that people can do easily but cannot describe as a list of instructions. Spam filtering is the standard example, and it is used throughout this lesson.
Worked example. A spam filter built entirely from written rules might develop as follows.
senders switch to “F-R-E-E M0NEY”; rule 1 sees nothing
rule 2 add a rule for the altered spelling
senders switch to “no cost cash”
rule 3 add a rule for that phrase
senders put the words in an image, where no text rule can read them
Each individual rule is easy to write. The problem is not difficulty but coverage: a rule-based filter requires its author to know every trick in advance, including tricks nobody has invented yet. The list of rules describes last month’s spam, and a sender who can test messages against the filter will always find the next gap.
Many problems have this shape. A person can tell junk mail from real mail in about a second, and cannot write down how the decision was made. The knowledge exists, but not in a form that can be turned into instructions.
Try it
- A fourth rule is added to the filter above: “if the message contains a link to an unfamiliar website, call it spam.” Describe one way a sender could get past it.
- State in one sentence why adding more rules does not solve the underlying problem.
Answers
1. Any change the rule does not anticipate works: for example, writing the web address as plain words instead of a link, or placing it inside an image.
2. Every rule covers only the tricks already known, so the filter is always one step behind whoever invents the next trick.
Learning from examples
The alternative is to write no rules at all and to supply examples instead. For the spam problem, that means gathering ten thousand emails that people have already sorted into two piles, spam and not spam, and handing the whole collection to a procedure.
A learning procedure is a program whose job is to find what the examples in one pile have in common that the examples in the other pile do not. It is not told what to look for. It searches, compares, and keeps whatever separates the piles best.
A model is what the learning procedure produces. Given a new example it has never seen, the model returns an answer. For the spam problem, the model is given a new email and returns a guess: spam or not spam.
Nobody wrote a rule about free money. If next year’s spam looks completely different, nothing is rewritten: newer examples are collected and the procedure is run again.
Figure 1 shows the most important feature of the second approach. The human work did not go away. It changed shape. Somebody still has to find ten thousand emails and sort them, and if that sorting is careless, everything built on it is careless too. Lesson 2 examines this sorting step in detail.
Machine learning is finding patterns in examples instead of following written instructions. The term means nothing more than that.
Try it
- In the learning-from-examples row of Figure 1, which box does a person produce, and which box does the computer produce?
- A learning procedure is given ten thousand labeled emails. Name what comes out, and say what it does.
Answers
1. The person produces the examples (the gold box). The learning procedure produces the model.
2. A model. Given a new email, it returns a guess about whether that email is spam.
What “learning” means here
The word learning suggests more than actually happens, and the gap should be understood from the start.
A spam model that is right 98% of the time has not understood anything. It has not worked out that some people try to take money from strangers. What it holds is a set of statistical regularities: certain words appear far more often in one pile than the other, messages with many capital letters lean one way, links to unfamiliar addresses lean the same way. These regularities are useful. They are not comprehension.
The distinction predicts where such a system fails. A model is confident and wrong on anything unlike what it was shown. A model trained only on English email knows nothing whatsoever about Spanish spam. This is not a flaw in its reasoning; it was never shown any Spanish spam, and it has no way of reasoning its way there.
Every learning procedure in this course needs the same three things. Each is treated in its own lesson.
2. a way to tell how wrong it is (Lesson 4)
3. a way to change itself and do better (Lesson 3 onward)
Remove any one of the three and no learning takes place.
Try it
- A spam model is right 98% of the time. State what it understands about why spam exists.
- A procedure has plenty of examples and a way to adjust itself, but no way to measure how wrong its answers are. Can it learn? Give a reason.
Answers
1. Nothing. It holds statistical regularities about which words and patterns appear in each pile, which is useful but is not understanding.
2. No. Without a measure of how wrong it is, it has no way to tell whether a change made it better or worse, so the adjustments have nothing to aim at.
Choosing between rules and examples
Both approaches are correct tools, and choosing the wrong one wastes a great deal of effort. The test for choosing between them is short.
Write the rule when the rule can be stated exactly. Tax owed on an income is defined in law, so the calculation is written out and is exactly right every time. Whether a chess move is legal is written in the rules of chess. A thermostat that turns the heating on below 18 degrees needs no training data and no examples. A written rule is faster, costs nothing to run, can be checked by reading it, and never produces a surprise.
Learn from examples when a person can recognize the answer but cannot write down how. Nobody can state the rule that separates one person’s handwriting from another’s, or spam from a real message, or a photograph with a dog in it from one without. In these cases the only thing a person can do is point at cases and say this one, yes; that one, no.
Machine learning is not the more advanced choice. It is the choice for when the rule cannot be written down.
The first question to ask about any problem is therefore whether the rule can be written. If it can, write it. If all a person can do is point at examples, the problem belongs to machine learning, and the next step is to understand what those examples must look like before any procedure can use them. That is the subject of Lesson 2.
Try it
- For each task, say whether it should be a written rule or a learned model: (a) working out the tax owed on an income; (b) deciding whose handwriting a note is in; (c) spotting whether a photo contains a dog; (d) deciding whether an email is spam.
- A school wants a program that says whether a student has enough credits to graduate. Which approach fits, and why?
Answers
1. (a) written rule, because the calculation is defined in law; (b), (c) and (d) learned model, because nobody can state the rule and can only point at cases.
2. A written rule. The number of credits required is stated exactly in the school’s policy, so the rule can be written down and checked by reading it.
Summary
- A rule-based program follows instructions a person wrote. It is exact, cheap to run and checkable, but its author must know every case in advance.
- Machine learning replaces written rules with collected examples. A learning procedure finds what separates the examples and produces a model, which answers new cases.
- The human work moves from writing rules to gathering and sorting examples. It does not disappear.
- A model that is right 98% of the time holds statistical regularities, not understanding. It is confident and wrong on anything unlike its examples.
- Every learning procedure needs examples, a way to tell how wrong it is, and a way to change itself.
- Write the rule when it can be stated exactly. Learn from examples when the answer can only be recognized, not described.
Key terms
- Rule-based program — a set of instructions written by a person and followed exactly by the computer.
- Learning procedure — a program that searches a collection of examples for whatever separates one group from another.
- Model — the output of a learning procedure; given a new example, it returns an answer.
- Machine learning — finding patterns in examples instead of following written instructions.
- Statistical regularity — a pattern that holds across many examples, such as a word appearing far more often in one pile than another.
Check your understanding
5 questions · 70% to pass · retakes encouraged
In the full course the graded quiz comes next and your progress is saved. Get access to continue.
Want the next free lesson by email? We post new free lessons and short tips for guiding your child with AI.
A short note when new free lessons are posted, plus occasional tips. No spam. Unsubscribe any time.That is the whole first lesson. The full AI For Youth: Grade 9 course has 8 lessons, 8 quizzes, and a project. One subscription unlocks every course, kindergarten through grade 12, plus AI Fundamentals for general audiences.
Get access