Skip to content
Return to course

Week 1 · Lesson 2 · 45-55 minutes

Rules Versus Learned Patterns

Look closely at automation and machine learning: when a person writes the rules, and when the software learns patterns from examples instead.

Materials
This lesson in a web browser · Paper and pencil, or a notes app
This lesson
In progress

Auto-saves on this device

What you'll be able to do

  • Define automation and machine learning and tell them apart.
  • Trace how input, rules, and output work in a traditional program.
  • Explain how a learned pattern replaces hand-written rules in machine learning.

Think about it

A thermostat turns on the heat when a room drops below 68 degrees. A music app builds you a playlist of songs 'you might like'. Both act on their own. Are they doing the same kind of thinking?

Make a prediction

Predict: which of the two — the thermostat or the playlist maker — needed someone to show it thousands of examples?

Automation
Making a task happen by itself using fixed rules, without a person doing each step.
Machine learning
A kind of AI where software learns patterns from many examples instead of being given every rule.
Rule
An exact instruction a person writes, like 'if the temperature is below 68, turn on the heat'.
Learned pattern
A regularity the software figured out from examples, used to make decisions on new inputs.

Automation: a task that runs itself on fixed rules

Automation means a task happens automatically by following rules a person set. A thermostat automates heating: 'if the room is below 68, turn on the heat.' No one has to flip a switch, but a human still wrote the exact rule.

Automation can be very useful and still not be AI. The machine is not learning — it is faithfully repeating instructions.

  • A thermostat heating a room at a set temperature
  • An automatic door opening when a sensor is pressed
  • A dishwasher running a timed wash cycle

Input, rule, output: the shape of a traditional program

Traditional programs and simple automation share the same shape: an input comes in, a rule decides what to do, and an output comes out. Input: room temperature. Rule: below 68 → heat on. Output: the heater turns on.

Because a person wrote the rule, you can predict the output for any input. This is powerful for tasks with clear, unchanging rules.

  • Input: a coin; Rule: coin detected → dispense gum; Output: gum
  • Input: a password; Rule: matches stored password → unlock; Output: unlocked

Machine learning: the software finds the pattern

Some tasks are too messy for a person to write every rule. What rule tells a good song recommendation from a bad one for you? Instead, machine learning shows the software many examples — songs you liked and skipped — and it learns a pattern it can apply to new songs.

The big shift: in machine learning, a learned pattern takes the place of hand-written rules. People still choose the examples and check the results, but they don't spell out every rule.

  • A playlist maker that learned your taste from songs you played and skipped
  • A handwriting reader that learned letter shapes from many samples

Worked example

Rule or learned pattern? Two ways to sort fruit

  1. Task: sort photos of apples and bananas.
  2. Rule way: a person writes 'if the shape is long and yellow → banana, else apple'. This works until a green banana or a yellow apple shows up.
  3. Learned way: show the software hundreds of labeled apple and banana photos; it learns the patterns of each, including tricky colors.
  4. The rule way is simple but brittle. The learned way handles new, unusual examples better — that's why messy tasks use machine learning.

Takeaway: Use fixed rules when the rule is clear and unchanging; use machine learning when the pattern is too messy to write by hand.

Input, rule, output

A three-step flow: Input (room temperature) → Rule ('below 68 → heat on') → Output (heater turns on). This is the shape of automation and traditional programs.

In automation, a person writes the rule in the middle.

Where the pattern comes from

Traditional

  • A person writes the rule
  • The program follows the rule

Machine learning

  • A person collects labeled examples
  • The software learns a pattern
  • The program uses the learned pattern

Before (traditional): a person writes the rule, then the program uses it. After (machine learning): a person collects labeled examples, the software learns a pattern from them, then the program uses that learned pattern. The person's job shifts from writing rules to choosing good examples.

Activity

Rule-Builder Challenge

Try to write fixed rules for a task, then see where fixed rules break and learning would help.

  1. Build an ordered list of rules. Rules are checked top to bottom; the first match wins.
  2. Run your rules on the starter creatures to see which rule matched each one.
  3. Then reveal the tricky creatures, predict what your rules will do, and revise.

Your rules (checked in order)

  1. Rule 1Ifthen

    If it has wings → Sky Creature

  2. Rule 2Ifthen

    If it lives in water → Water Creature

  3. Rule 3Ifthen

    If the number of legs is at least 1 → Land Creature

Fixed-rule program (what you just built)

  • A human writes explicit rules
  • Behavior is predictable and easy to explain
  • Can fail when a situation wasn't covered

Machine-learning system

  • Learns patterns from examples
  • May handle varied examples better
  • Can make mistakes that are hard to explain
  • Still depends on human choices and the data it's given

Neither is always better. Fixed rules shine when the rule is clear; machine learning helps when the pattern is too messy to write by hand — but it needs good examples and careful checking.

Check your understanding

Check that you can tell automation from machine learning.

  1. Question 1. What is the main difference between automation and machine learning?

  2. Question 2. Put the steps of a traditional program in order.

    1. 1.An input arrives (like a temperature reading)
    2. 2.A rule a person wrote decides what to do
    3. 3.An output happens (like the heater turning on)
  3. Question 3. Which task is a better fit for machine learning than for hand-written rules?

    You want software that (A) turns on a fan when the room is above 80 degrees, or (B) tells whether a photo shows a dog or a cat.

0 of 3 answered

Try it yourself

Rule it or learn it?

Come up with two tasks: one that fixed rules handle well, and one that needs machine learning.

  1. Describe a task where a person can easily write the rule. State the rule.
  2. Describe a task that is too messy for fixed rules. Explain why.
  3. For the messy task, what examples would you collect to teach it?

Success looks like

  • One clear rule-based task with its rule.
  • One learning-based task with a reason rules won't work.
  • A description of the examples needed to teach the messy task.

Reflection

Saved on this device as you type

Please don't include private information. Your answers are saved only in this browser and are never sent anywhere.

Recap

Automation repeats fixed rules; machine learning learns patterns from examples for tasks too messy to rule out by hand.

  • Traditional programs follow input → rule → output.
  • Machine learning replaces hand-written rules with a learned pattern.
  • People still pick the examples and check the results in machine learning.

Grades 7–8 extension

Who decides the examples?

In machine learning, the examples a system learns from are chosen by people. That means human decisions are built into every model — which examples to include, and what the correct label is.

Think of a task you'd teach a model. Who would choose the examples, and how could their choices change what the model learns?

Finish this lesson

  • Attempt the knowledge check — not done
  • Save a reflection (recommended) — not done

Attempt the knowledge check to finish this lesson.