When rules run out: why computers need to learn

Beginner5 min readPart 9 of 9

Some jobs are too messy to write rules for. See why, and how that leads to machine learning.

You have learned a lot about how computers work. They take in bits, follow clear instructions, and do billions of tiny steps a second. If you can write down the steps, a computer can do the job.

But what if you cannot write down the steps?

Jobs that rules handle well

Some jobs are perfect for rules:

For each of these, a clear list of steps always works. That is what normal programming is brilliant at.

Jobs where rules fall apart

Now try this: write rules to decide whether a photo shows a cat.

Every rule you write has exceptions, and every exception needs another rule. You could write thousands and still be wrong.

It is the same for many jobs that people find easy:

We know how to do these things, but we cannot explain our own steps. Try telling someone how you recognise your friend's face. You cannot, you just do.

A different idea: learn from examples

Instead of writing the rules, what if the computer found them itself?

  1. Collect lots of examples as a table of numbers (remember: everything can be numbers).
  2. Tell the computer what counts as a good answer.
  3. Let the computer practise, adjusting its own settings to do better.

Then the computer finds its own rules, hidden in thousands of numbers, that no person had to write. This is machine learning.

Rules (normal programming)Learning (machine learning)
Who finds the steps?A personThe computer, from examples
What you provideThe rulesLots of data, and a goal
Best forClear, exact jobsMessy jobs with lots of variety
ExampleA calculatorRecognising faces in photos

Learning is not always better

It is not magic, and it is not always the right tool:

Good engineers pick the right tool for each job. Often they combine the two.

You are ready

You now know the building blocks: bits, numbers, gates, processors, algorithms, programs and data. That is enough to understand what machine learning is really doing. In the next lesson, you will meet it.

Play first

You can also jump straight into Train the Puppy. The puppy has no rules. It learns its own by practice, and you set the rewards.

Words to know

Rule
A clear step or instruction written by a person.
Exception
A case that the rule does not cover.
Machine learning
Computers finding their own rules from examples or practice.

Check yourself

  1. Give one job that rules are good at and one where rules fall apart.

    Show the answer

    Good: adding a bill, sorting names, finding a route. Bad: recognising a cat in a photo, reading handwriting, understanding speech.

  2. Why is it hard to write rules for recognising a cat?

    Show the answer

    Every rule has exceptions, such as foxes with pointy ears or hairless cats, and you would need endless rules.

  3. In machine learning, who finds the rules?

    Show the answer

    The computer does, by practising on lots of examples.

  4. Is machine learning always better than normal programming?

    Show the answer

    No. For clear, exact jobs like a calculator, plain rules are better. Learning suits messy jobs with a lot of variety.