Module 0 · Lesson 1 of 10

What a model is: learned from examples

A model learns from examples

Training adjusts a model's numbers using marked examples, also called labelled data, and a test on new examples shows whether it learned.

Scene 1 of 5 · Examples, not rules

A spam filter starts from 10,000 emails, each one marked spam or not spam by a person.

Marked examplesMarked examples10,000 marked emailsTrainingTrainingThe modelThe modelYour appYour app
  • Marked examples — healthy — 10,000 marked emails
  • Training — healthy
  • The model — healthy
  • Your app — healthy
  1. Examples, not rules. A spam filter starts from 10,000 emails, each one marked spam or not spam by a person.
  2. Nudge the numbers. Training compares each guess with its mark and shifts the model's numbers towards the right answer.
  3. Test on new emails. Scored on fresh emails, it is right 96 times in 100, close to its 99 on old ones.
  4. Memorising is not learning. A model that memorised its examples scores 100 on them but 71 on new ones.
  5. Inference: use it. Your app sends a new email and gets a label back, and the numbers no longer change.
  6. Now you try. Pick a task, and see whether it suits plain code or a trained model. For example: Plain code. The rule is known and must be exact every time, so a guess that is usually right is not good enough.

Scene 1 of 5: Examples, not rules. A spam filter starts from 10,000 emails, each one marked spam or not spam by a person.

Key points

  1. A model's rules come from examples, not from a person writing them.
  2. Training nudges its numbers until its guesses match the marked answers.
  3. Only a score on unseen examples shows that it learned.
  4. Your app runs the finished model; its numbers stay fixed while it answers.

Most software follows rules a person wrote, such as "orders over $50 ship free". A model is different: nobody writes its rules. It learns patterns from many examples.

shows the model examples, such as emails a person marked as spam or not spam. Examples marked like this are called labelled data. It compares its guesses with the marked answers, and adjusts its internal numbers, called , so the next guesses are a little better.

Training is slow and costly, and it happens before anyone uses the model. Using the finished model to get an answer is called . Most AI features call a model someone else trained, so they run inference only.

A model is judged on examples it never saw. One that memorised its training examples does well on them and badly on new ones, which is called . Where the rules are known and must be exact, such as tax or permissions, plain code is the better tool.

Example. Illustrative: a spam filter learns from 10,000 marked emails. On 1,000 emails it never saw, it labels 960 correctly. Mistakes like those 40 are normal for a model, so costly cases need a rule or a person.

In system design: Treat a model as a part that is usually right, not always. Keep exact rules, such as prices and permissions, in plain code.

Check yourself

A spam filter scores 99 in 100 on the emails it trained on, but 70 on new emails. What does that suggest?