Lesson 01 · Rules vs. learning · 8 min

What is AI, really?

Ordinary software follows rules a person wrote. Machine learning flips that around: you show the computer examples and it works out the rule for itself. Let's feel the difference with a spam filter.

✍️ Write a rule by hand📈 Watch a model learn🧪 Break it with new data
1

Be the programmer: write a spam rule

Each dot is an email. Across is how many links it has; up is how many SHOUTY WORDS!!! it uses. Coral dots are spam, blue dots are real mail.

Drag the sliders to write a rule: "If it has more than X links or more than Y shouty words, it's spam." Anything in the shaded zone gets flagged. How high can you get the accuracy?

hand_written_rule.pyif links > 6 or shouts > 6: spam
Accuracy–
Missed spam–
Real mail flagged–

Tip: a perfect score is hard. Real emails sometimes shout, and some spam is quiet. Rules made of straight cut-offs struggle with that.

2

Now let the machine learn the rule

This is a perceptron, one of the oldest learning algorithms (1958!). It starts with a random dividing line. Each step it finds an email it got wrong and nudges the line a little towards the right answer. That nudge is what "learning" means.

Press Train and watch the line find its way. Wrong guesses pulse.

perceptron.learn()
Accuracy–
Updates0
Your rule–
Add your own emails. Click the chart to drop new spam, or switch to real mail first. Then train again and the model adapts. Your hand-written rule doesn't.
3

So what is "AI"?

Artificial intelligence is a broad term for computers doing things that seem to need intelligence: recognising faces, translating languages, playing chess, writing text.

Most modern AI is machine learning: instead of hand-writing every rule, we write a learning procedure and feed it lots of examples. The perceptron learned from 40 emails. Today's language models learn from trillions of words, but the core idea is the same: guess, measure the error, nudge, repeat.

Later in the course we'll stack these learners into agents that don't just answer questions but take actions. First, we need to see what's inside the box.

✓

Quick check