Objectives
By the end of this lesson, you will be able to:
- Explain how traditional programs follow rules written by people
- Explain how machine learning finds its own rules from examples
- Decide which approach fits a given problem
Key terms
- Program
- A set of instructions a computer follows exactly.
- Machine learning
- A way of building AI in which the system finds patterns in examples instead of being given every rule by a person.
- Training
- The process of showing a machine learning system examples so it can find patterns.
Reading
The traditional way: write the rules
Most software works because a person wrote down exactly what to do. A calculator adds because someone programmed the rules of addition. A traffic light changes because someone set the timing. If you know the rules, you can predict exactly what the program will do.
This works beautifully when the rules are clear. It breaks down when they are not. Try writing rules that tell a computer whether a photo contains a dog. "Four legs" also describes a table. "Fur" also describes a coat. Dogs come in every shape, color and pose. No one can write that rulebook.
The machine learning way: learn from examples
Machine learning turns the problem around. Instead of writing rules, you collect examples: thousands of photos labeled "dog" and thousands labeled "not dog." A learning algorithm processes them and adjusts itself until it can tell the two groups apart. The result is a model.
Nobody typed the rules the model ended up using, and often nobody can fully read them. The model simply reflects the patterns that were in its examples. That is the source of both its power and its weaknesses, and it is the thread that runs through this whole curriculum.
Choosing the right approach
Learning is not always better. Rules are the right choice when the logic is known, when mistakes are costly, and when you must be able to explain every decision, like calculating a tax bill.
Learning is the right choice when the task is easy for people to do but hard to describe, and when you have many good examples: recognizing speech, spotting spam, reading handwriting.
Most real products mix the two. A voice assistant uses machine learning to turn your speech into text, then ordinary rules to set the timer you asked for.
Try it · Interactive lab
Rules or learning?
For each task, choose the approach an engineer would reach for first.
Work out the total price of a shopping cart with tax
Group activity 20 min
Be the rule-writer, then be the learner
You will need
- Paper and pens
- A set of about 20 simple hand-drawn shapes or printed pictures (for example, fruit) for each group
- 1
Round one, rules. In groups, write a list of rules that would let someone who has never seen an apple or a tomato tell them apart using only your instructions. No pictures allowed.
- 2
Swap rule lists with another group. Test them on tricky cases: a green apple, a cherry tomato, a red pear. Count how many the rules get wrong.
- 3
Round two, learning. One person is the learner and closes their eyes. The others show them ten labeled pictures one at a time ("this is an apple"), then test them on new ones.
- 4
Compare. Which approach handled the tricky cases better? What would have happened if all the training apples had been red?
Discuss
- Q1
Why was it so hard to write rules for something you recognize instantly?
- Q2
If the learner only ever saw red apples, what mistake would they make? What does that tell you about the examples a model learns from?
- Q3
Think of a task at school or at home. Would you solve it with rules or with learning? Why?
Write your answer to one of the questions. Saved only on this device.
Quick check
Choose an answer to see whether you were right, and why.
Key takeaways
- Traditional software follows rules that people write.
- Machine learning finds its own patterns from examples.
- A model can only be as good as the examples it learned from.