Book an info sessionInfo session

Learning from examples, not rules

AI Explorers · lesson 10 of 24 · 25 min

Nobody gave you a rulebook for telling your aunt’s laugh apart from your uncle’s. You just heard them enough times. Machine learning works in a similar way.

Two ways to teach a computer

In Unit 3, people wrote the rules. That works for small problems. But try writing rules to recognize a cat in a photo. “Has pointy ears”? So do foxes. “Has fur”? So do dogs. You would never finish.

Machine learning (ML) flips the approach. Instead of writing rules, we give the computer lots of examples, and it finds the patterns itself.

Traditional programmingMachine learning
People write the rulesThe computer finds the rules
Input: data + rulesInput: data + correct answers
Output: answersOutput: a model that can make answers
Good when rules are clearGood when rules are hard to write down

What is a model?

The thing machine learning produces is called a model. A model is like a recipe the computer created from all the examples. When you give the model something new, it uses that recipe to make a prediction.

For example, imagine training a model on hundreds of photos of ripe and unripe bananas. Afterward, you show it a banana it has never seen. The model predicts “ripe” or “unripe,” often with a confidence score like “90% sure it’s ripe.”

A model’s confidence is not a promise. It means “based on my examples, this looks a lot like ripe bananas.” If the new picture is weird, like a banana in purple light, the model can be confidently wrong.

The learning loop

Most machine learning follows a loop:

  1. Collect examples.
  2. Train: the computer studies the examples and adjusts its model to make fewer mistakes.
  3. Test: check the model on new examples it has not seen.
  4. Improve: if it makes mistakes, add better examples or change settings, then train again.

Training is a lot of small adjustments. The computer makes a guess, checks the right answer, and nudges its internal numbers to do a little better next time. Repeat that thousands or millions of times, and the guesses get good. You will run this loop yourself in Unit 5.

Machine learning is not the right tool for every job. If the rules are simple and clear, like calculating a sales tax or checking whether a password is long enough, normal programming is faster, cheaper and easier to explain. Machine learning shines when the pattern is real but hard to put into words, like recognizing a voice, a face or a song.

Try it

This is a pattern-finding game for two or more people.

  1. One person is the “trainer.” They secretly pick a rule for sorting words, like “words with double letters” or “things that are found in a kitchen.” Don’t say it out loud.
  2. The trainer says 8 words one at a time and says “yes” or “no” for each one. Example: “spoon: yes. car: no. pan: yes.”
  3. The other players are the “model.” After each word, they write down their guess of the secret rule.
  4. Now the trainer gives 4 new test words. The model players predict “yes” or “no” for each before hearing the answer.
  5. Count how many test words each player got right. Then reveal the rule and talk about which examples helped most.

Check yourself

How is machine learning different from writing rules?

In machine learning, the computer finds the patterns from examples instead of people writing every rule.

What is a model?

What machine learning produces: a learned pattern-recipe that makes predictions about new inputs.

If a model says it is 95% confident, is it always right?

No. Confidence means the input looks like its examples. It can still be wrong, especially on unusual inputs.

Key words

  • Machine learning (ML): computers learning patterns from examples.
  • Model: the learned result of training, used to make predictions.
  • Training: the process of a computer learning from examples.
  • Confidence: how sure a model is about a prediction.

Previous lesson: Search: how computers find the best path
Back to AI Explorers
Next lesson: Training data and labels