An email promises a free prize. Another confirms your free workshop place. One belongs in spam; the other might be exactly what you were waiting for.
A rule that blocks the word “free” cannot tell them apart. Could a computer learn a better rule from examples?
That is our starting point. By the end, you will have followed a small learning algorithm, tested its chosen model and discovered why a model can make a perfectly consistent prediction that is still wrong.
If you have read What Is Artificial Intelligence?, this is the next step: from the broad idea of learning from data to what that process actually involves.
What machine learning actually means
Machine learning is an approach to building systems that learn patterns from data, rather than relying entirely on people to write every decision rule. It is one part of the wider field of AI. ¹
Consider two ways to build an email filter:
- Traditional rule-based programming: a developer decides that messages containing “free” should go to spam, then writes that instruction.
- Machine learning: a developer sets up a learning procedure, supplies examples and defines how to judge its results. Training produces a model that can classify new messages.
People still make crucial choices. What counts as spam? What information can the model use? Which kinds of model may it learn? What errors should matter most?
Also, a learned model can itself be a set of rules. Decision trees are one example: training learns rules from data. ² The distinction is how those rules were obtained, not whether the final system contains any rules at all.
Four terms, one inbox
For our filter, the task is to predict one of two categories: spam or not spam. This is called classification.
Here are the ingredients of this supervised learning task: ³
| Term | In our email example |
|---|---|
| Training data | Examples used to fit the model. |
| Features | The information supplied as input—for this exercise, two yes/no clues about each email. |
| Label | The answer attached to a training example: spam or not spam. |
| Model | The learned mapping from inputs to predictions. Here, it will be a selected rule. |
The label is the answer we want the model to predict. It is not an extra clue we hand it when a new email arrives.
For now, our model gets only two features:
- Does the subject contain the word “free”?
- Is the sender outside your contacts?
We can read the complete subject. The model cannot: it receives only those two yes/no values. Keep that difference in mind.
Try it: train a very small spam filter
Try It with Byte

Let’s give the learner three possible rules and let the examples decide. You can check every decision yourself.
1. Inspect the examples
These are fictional teaching examples, not a real email dataset. We have assigned labels using the imagined sender and consent context: messages 1, 2 and 6 are unsolicited promotions; the others are expected messages. The subject alone does not establish that context.
Here, “free” means the standalone word, ignoring capitalisation. A sender being outside your contacts does not make them unsafe—or make a contact trustworthy.
| Email subject | Contains “free”? | Outside contacts? | Training label |
|---|---|---|---|
| 1. Free voucher—claim now | Yes | Yes | Spam |
| 2. Free prize waiting | Yes | Yes | Spam |
| 3. Free workshop booking confirmed | Yes | No | Not spam |
| 4. Your delivery is scheduled | No | Yes | Not spam |
| 5. Friday meeting notes | No | No | Not spam |
| 6. Claim your cash reward | No | Yes | Spam |
| 7. Your appointment is confirmed | No | Yes | Not spam |
2. Let the learner choose
Our tiny learning algorithm tries exactly three candidate rules. Each predicts not spam when its condition is absent:
- Rule A: predict spam when the subject contains “free”.
- Rule B: predict spam when the sender is outside your contacts.
- Rule C: predict spam only when both conditions are true.
Training means applying each candidate to the seven examples, counting its mistakes and selecting the candidate with the fewest. Before checking the scores, which would you choose?
Compare the three rules on the seven labelled emails.
Training results
| Candidate | Mistakes on the seven training examples | Which emails? |
|---|---|---|
| A: “free” | 2 | 3 and 6 |
| B: outside contacts | 2 | 4 and 7 |
| C: both | 1 | 6 |
Rule C wins. It is our trained model.
It has not discovered the meaning of spam. It has found the lowest-error option among the three rules we allowed it to consider, using the examples we supplied.
That is a deliberately tiny learning setup. We programmed the candidates and the selection procedure; the data determined which candidate became the model. Other methods can search much larger possibilities or adjust many numerical parameters. This exercise is not a description of a production email filter.
3. Freeze the model and try new emails
Training is finished. Now apply Rule C without changing it. Using a trained model to make a prediction is inference. ³
For each message, predict what the model will say—not what you think the message deserves.
| New email subject | Contains “free”? | Outside contacts? |
|---|---|---|
| 8. Free entry pass for your booked event | Yes | Yes |
| 9. Your reward is waiting | No | Yes |
| 10. Tomorrow’s meeting agenda | No | No |
Check your predictions
| Model prediction | Label in our fictional scenario | What happened? | |
|---|---|---|---|
| 8. Booked-event pass | Spam | Not spam: a requested pass from a new organiser | Wanted mail was flagged. |
| 9. Reward message | Not spam | Spam: an unsolicited promotion | Spam was missed. |
| 10. Meeting agenda | Not spam | Not spam: an expected message from a contact | Correct. |
The model followed its learned rule exactly. Two of its three predictions were wrong. These hand-picked examples demonstrate failure modes; they do not estimate how well a real filter would perform.
The information the model never received
Compare email 1, the unsolicited voucher, with email 8, the requested event pass. Their situations differ, but both become the same input:
Contains “free”: yes. Outside contacts: yes.
Our fixed, deterministic model must give identical inputs the same prediction. It cannot use the difference between “I requested this” and “I never asked for this” because we did not supply that information.
Outside contacts = yes
Outside contacts = yes
More examples might make the learner choose a different rule. But with these same two inputs, no deterministic rule can reliably separate those two messages. It needs information that distinguishes them—perhaps whether the recipient requested the message, if that signal is available and reliable.
That is the lesson hiding inside “learns from data”: the model learns from the information it is given, not everything a person can see in the situation.
What counts as a mistake?
We made every wrong prediction cost one point. That choice helped determine which rule won.
In machine learning, the training objective specifies what the learning procedure tries to optimise. A loss measures prediction error; many training procedures adjust a model to reduce it. ⁴
But errors are not always equally costly. Flagging your interview invitation as spam and letting an unwanted advert into your inbox are different failures. In classification, these are a false positive and a false negative, respectively. How a system balances them depends on its purpose; changing a decision threshold can change that balance. ⁵
Our exercise uses a simple mistake count so you can inspect it. A real project must ask whether its chosen objective and evaluation measures reflect what users actually need.
Does a good training score mean it has learned well?
Byte’s Reality Check

Not yet. A training score tells you how well a model fits examples it has already used. You also need to know whether it works on fresh, relevant examples.
Generalisation means performing well beyond the training data. Overfitting happens when a model fits the training examples too closely—including details that do not carry over—and performs worse on new examples. ⁶
Our toy filter’s mistakes do not, by themselves, prove overfitting. Its limited inputs already prevent it from distinguishing certain messages. Missing information, unsuitable model choices and a mismatch between training data and real use can also cause poor predictions.
For a more trustworthy evaluation, keep some examples out of training. Use a validation set to compare choices and tune the system, then a separate test set for a final check. Repeatedly changing the model in response to test results undermines that test’s independence. ⁷
Our three new emails are teaching probes, not a sufficient evaluation dataset. Real checks need enough relevant examples to examine the errors that matter, including performance across different situations. Once deployed, a model also needs monitoring: incoming data and behaviour can change. ⁸
Not all machine learning uses spam labels
Our exercise is supervised learning: it learns from examples paired with target answers. Two other important approaches use different feedback. ¹
| Approach | What guides the learning? | A practical example |
|---|---|---|
| Supervised learning | Examples with target labels or values | Classifying spam, or estimating a house’s sale price. |
| Unsupervised learning | Structure in data without supplied target answers | Grouping customers with similar purchasing patterns. People still need to interpret whether the groups are useful. |
| Reinforcement learning | Rewards from actions taken in an environment | Training an agent to play a game, where actions affect later situations and rewards. |
A reinforcement-learning reward is not necessarily a correct-answer label for each individual action. A move may matter because of what happens several steps later.
The kind of feedback changes, but the same practical question remains: what behaviour does this setup encourage the system to learn?
Take the idea beyond email
A house-price model offers a useful contrast. Its features might include floor area, location and number of bedrooms; its training label could be the recorded sale price. The output is a number rather than a category—a task called regression. ¹ ³
Now apply what the inbox taught us. If important differences between properties are absent from the inputs, the model cannot directly use them. If the recorded prices are wrong, the examples teach the wrong targets. If the market changes, yesterday’s relationships may become less useful.
Three questions make almost any machine-learning claim easier to assess:
- What information did the model receive? Check what is missing as well as what is included.
- What was it trained to get right? A convenient score is not automatically the same as a useful outcome.
- Where has it been checked? Ask about relevant unseen examples and current use, not only training results.
More data can help, but it cannot automatically repair unreliable labels, unrepresentative examples or missing information. Nor does a correct prediction establish that the model understands the situation as a person would.
Deep learning belongs within machine learning and uses neural networks with multiple layers. Such models can learn richer representations than our two hand-chosen clues, but still depend on their inputs and training setup. ⁹ That is where our learning path goes next.
Key takeaways
- Machine learning uses data to fit a model; people still choose the task, inputs and learning setup.
- Features are inputs. Labels are target answers in supervised learning. The model turns inputs into predictions.
- Training selects or adjusts the model. Inference applies it to a new input.
- A good training score is not enough: check generalisation and the mistakes that matter.
- Two different situations can look identical to a model when its inputs omit the difference.
Continue your learning path
Previous: What Is Artificial Intelligence? — the broader picture.
You are here: Byte Explains #2 — What Is Machine Learning?
Next: What Is Deep Learning? — how neural networks extend the idea of learning from examples.
Browse the Evergreen AI learning hub for more fundamentals.
Sources and further reading
The email dataset, candidate rules and results in this article are an original illustrative teaching exercise. They are not measured results from a deployed spam filter.
- Google — What is machine learning?: learning approaches, classification and regression.
- scikit-learn — Decision trees: models that learn decision rules. Our fixed three-rule learner is a separate simplification, not this library’s tree algorithm.
- Google — Supervised learning: features, labels, models, training and inference.
- Google — Linear regression: Loss: loss as a measure of prediction error. Our exercise uses a mistake count, not the regression losses illustrated in this source.
- Google — Classification: Thresholds and the confusion matrix: false positives, false negatives and their trade-offs.
- Google — Overfitting: overfitting and generalisation.
- Google — Dividing datasets: training, validation and test data.
- Google — Monitoring production ML systems: checking performance across data subsets and monitoring changing real-world inputs.
- Google — Neural networks: learning more complex relationships through neural-network architectures.
The example data are fictional; the rule scores were checked by calculation.