← Back to course
AI Explorers 3-5 / Week 05 / Thursday
4/6
Week 05 Β· Rules or Learning?

Thursday

Compare the two ways
// Two ways to build a helper
⏱ about 15 min

Thursday: Compare the Two Ways

Rocket and Raven race to sort the photo pile. Rocket uses his rule list. Raven studies example photos.

"My rules are fast and clear!" Rocket says.

"But what do you notice?" Raven asks. "Your rules keep missing the metal ruler."

Nova hovers between them. "Each way has strengths," she hints. "Which fits this job best?"

Strengths of each way

RulesLearning from examples
Who does the main work?A person writes every ruleThe computer finds patterns in data
What does it need?A rule for every caseA huge number of examples, usually from people
In our labPart A: you followed a rule you were givenPart B: you found the pattern yourself
In our photo storyRocket's rules kept breaking on tricky photosThe crew will try this next week

Rules are clear. You can read each rule and see why the computer chose.

Learning from examples finds patterns in data. It needs a huge number of examples.

Those examples are usually given by people.

If a job has too many cases to write rules for, examples may fit better.

Programmers compare both ways and pick the one that fits the job.

WHICH WAY FITS THE JOB?
  • Read the question.
  • Tap your answer.
Job: add two numbers. Which way fits best?
Job: tell happy drawings from sad drawings by 100 different kids. Which way fits best?
Job: turn on a light at 7 every night. Which way fits best?
Job: sort thousands of mission photos with many tricky ones. Which way fits best?

Compare like a programmer

To compare two ways, test them on the same job.

Count how many each one gets right.

Then think about what each one needs.

WayPhotos testedSorted right
Rocket's rules107
Raven's examples109

These are made-up practice numbers for our story.

How many photos did Rocket's rules get wrong?
How many photos did Raven's examples get wrong?
Which way sorted more right? Type rules or examples.
StatementTrue or false?
Rules are easy to read.?
Learning from examples needs only one example.?
Examples are usually given by people.?
A fair comparison tests both ways on the same job.?
WHY THIS EXERCISEComparing fairly helps programmers pick the best way for a job.
COMPARE TWO WAYS FAIRLY
  • ?Pick one job to do.
  • ?Build it with examples.
  • ?Test both on the same photos.
  • ?Build it with rules.
  • ?Count and compare the results.
WHY THIS EXERCISEUsing the same job and the same test keeps the comparison fair.
Does learning from examples need a few or a huge number of examples? Type few or huge.
WHY THIS EXERCISEMachine learning needs a huge number of examples to find good patterns.
Try it
Pick a job at home, like sorting forks and spoons.
Write two if-then rules for it. Then show someone three examples instead.
Which way taught the job faster?

You compared like a real programmer! Tomorrow we review and look ahead to training data.

← Wednesday