A.4 Machine learning
Train and evaluate a simple classifier
Distinguish training from prediction and explain generalization, bias, and evaluation.
Examples use Python. HL includes additional lessons beyond the SL path.
Learn a pattern from examples
In supervised learning, training examples contain features and known target labels. A spam classifier might use features of messages and labels such as spam or legitimate. Training adjusts the model using those examples; prediction applies the learned model to a new message.
Unsupervised learning instead looks for structure without supplied target labels, such as clusters of similar messages. The clusters are not automatically meaningful categories; someone still needs to interpret the result in context.
Evaluate on unseen data
A model can memorize its training data and perform poorly on new examples. Keep test examples separate from training, and avoid leaking the answer through a feature. Evaluate data representative of the people and situations where the model will be used.
If 95 of 100 messages are legitimate, a model that always says legitimate has 95% accuracy while missing every spam message. Inspect false positives and false negatives and explain their different consequences for the user.
| Predicted spam | Predicted legitimate | |
|---|---|---|
| Actual spam | 4 | 1 |
| Actual legitimate | 3 | 92 |
Check yourself
Why is training accuracy insufficient evidence that a model will work well?Show answer
It measures examples already used to fit the model. Unseen, representative test data is needed to assess generalization.
References used to build these lessons
We used these official documents as references when building this course's lessons. They are the sources for the syllabus structure and course requirements.
International Baccalaureate · First assessment 2027
This PDF is the public IB subject brief. The complete subject guide and assessment requirements are available through your school or the IB Programme Resource Centre.