← Back to course
2/6
Week 05 Β· Rules or Learning?

Tuesday

Inside hand-written rules
// Hand-written rules versus patterns found in data
⏱ about 20 min

Tuesday: Inside Hand-Written Rules

Raven pins Sky Sorter version 1 on the wall next to Rocket's patched version.

"Both are hand-written," she says. "Each threshold is a number one of us chose."

Rocket points at his 215. "I picked that because card E was 210. I was only fixing one card."

Nova shines a light on the pseudocode. "Hand-written rules have a strength too," she says.

"Anyone can read them and see exactly why a card got its label."

Raven nods. "So what is the weakness?" Rocket sighs. "Someone has to know the right rule first."

Strengths and weaknesses

Hand-written rules are clear. You can trace them line by line, like we did with pseudocode.

They work well when a job has a simple, known rule, like converting minutes to seconds.

But someone has to know the right rule and the right threshold.

If the person guesses a threshold from only a few cards, the rule may fail on new ones.

ROCKET'S PATCHED RULES
IF streak is yes THEN label = "satellite streak"
ELSE IF size >= 8 THEN label = "comet"
ELSE IF brightness >= 215 THEN label = "planet"
ELSE label = "star"
TRACE ROCKET'S PATCHED RULES
  • Read the question.
  • Tap your answer.
Card E: brightness 210, size 3, streak no. What label now?
Raven's card: brightness 205, size 6, streak no. It is really a planet. What label do the rules give?
Card B: brightness 230, size 5, streak no. What label?
JobIs there a simple known rule?Better fit
Turn minutes into secondsYes: multiply by 60Hand-written rule
Decide if a year number is evenYes: divide by 2Hand-written rule
Sort thousands of blurry snapshotsNo: there are too many tricky casesLearning from data
StatementTrue or false?
Hand-written rules are easy to trace and explain.?
Turning minutes into seconds needs machine learning.?
A threshold picked from one card can fail on new cards.?
The computer changes hand-written rules by itself.?
WHY THIS EXERCISEHand-written rules are clear, but only as good as the person who wrote them.
HOW ROCKET PATCHED HIS RULE
  • ?Find that a different planet card now fails.
  • ?Pick a new cut-off just above it, 215.
  • ?Look at card E's brightness, which was 210.
  • ?Notice that card E got the wrong label.
WHY THIS EXERCISEPatching from one card at a time is why the rule kept breaking.
How many seconds are in 3 minutes?
In the patched rules, which feature uses the 215 cut-off?
Is the year 2030 even? Type yes or no.
WHY THIS EXERCISEA job with a simple known rule does not need learning from data.
PICK THE BETTER FIT
  • Read the question.
  • Tap your answer.
Job: convert a temperature from one scale to another with a known formula. Better fit?
Job: tell thousands of handwritten letters apart, written by many different people. Better fit?

Sharp thinking! Tomorrow in the Explorer Lab, you let the data choose the cut-off.

← Monday