IB Computer Science · A4 · Machine learning
A4.1 Machine learning fundamentals
Describe what machine learning is, explain the role of training data, and outline the common tasks and workflow.
1/5Machine learning lets programs learn rules from data
Part 1 of 5: Machine learning lets programs learn rules from data
A spam filter could be written by hand, with one rule for every suspicious phrase. That list would never be complete. Machine learning takes another route: the program finds patterns in examples and builds its own rules.
In traditional programming, a person writes the rules and the computer applies them to data to get answers. In machine learning, the computer receives data and known answers, then produces the rules. These learned rules form a model.
Key terms · tap one for its definition
machine learning
Machine learning is the use of algorithms that learn patterns from data to make predictions or decisions without being given explicit rules.
model
A model is the set of rules or patterns, produced by training, that is used to make predictions on new data.
Part 2 of 5: Training data shapes what a model can learn
Since a model comes from examples, the examples matter a great deal. The examples used to build it are the training data. Each example has several inputs. Each input is a feature, a measurable property such as a house’s floor area.
Many tasks also give each example a label, the known correct answer, such as the house’s sale price. The model compares its guesses with the labels and improves.
A model can only reflect patterns that its data contains. Too few examples, or examples that miss common cases, give a weak model. Both the quality and the quantity of data count.
Key terms · tap one for its definition
training data
Training data is the set of examples from which a model learns its rules.
feature
A feature is a measurable property of an example that is given to a model as input.
label
A label is the known correct output attached to a training example.

Quick check
One question on the part you just read
Easy
Show answer and explanation
Answer: A · Worked explanation
Part 3 of 5: Held-back data shows how well a model generalises
Training data alone cannot show whether a model works. A model might simply memorise its examples. So some data is kept back as testing data, and the model never sees it during training.
Accuracy on the testing data estimates how the model will perform on new cases. A model that scores well on training data but poorly on testing data shows overfitting. It has learned quirks of its examples instead of the general pattern.
Key terms · tap one for its definition
testing data
Testing data is a set of examples, kept separate from the training data, used to measure how well a model performs on unseen cases.
overfitting
Overfitting is the fitting of a model so closely to its training data that it performs worse on new data.
Part 4 of 5: Machine learning solves several common kinds of task
With the data question settled, consider what models are used for. Five kinds of task appear often.
- Sorting items into categories, such as spam and not spam.
- Predicting a number, such as the price of a house.
- Grouping similar items when no categories are given, such as customer groups.
- Recommending items a user may like, based on past behaviour.
- Spotting unusual cases, such as a suspicious card payment.
Image recognition is a familiar example of the first kind. Each picture is assigned to a category, such as cat or dog.

Quick check
One question on the part you just read
Easy
Show answer and explanation
Answer: C · Worked explanation
Part 5 of 5: A workflow turns a problem into a working model
Real projects follow a repeatable sequence. Each step feeds the next, and poor results often send you back to an earlier step.
- Define the problem and decide how success will be measured.
- Collect the data and prepare it for use.
- Split the data into training and testing sets.
- Train a model on the training data.
- Evaluate the model on the testing data.
- Deploy the model and monitor it on real data.
If evaluation is poor, you might collect more data or change the model. After deployment, accuracy can fall as real-world data changes, so monitoring continues.
Key term
deployment
Deployment is the stage at which a trained model is put into real use to make predictions on new data.
Check your recall[14 marks]
5 written questions. Answer each one in your head or on paper, then open the mark scheme.
- 1.Distinguish[3 marks]
Distinguish between traditional programming and machine learning.
Show mark schemeHide mark scheme
Model answer
In traditional programming a person writes the rules, and the computer applies them to data to give answers. In machine learning the computer is given data, often with known answers, and produces the rules itself. The learned rules form a model.
- 1 mark for stating that in traditional programming a person writes the rules
- 1 mark for stating that in machine learning the computer learns the rules from data
- 1 mark for stating that the learned rules form a model that is applied to new data
- 2.Explain[3 marks]
Explain why data is split into training and testing sets.
Show mark schemeHide mark scheme
Model answer
The model learns from the training set. The testing set contains cases the model has not seen. Accuracy on it estimates how the model will perform on new data and can reveal overfitting.
- 1 mark for stating that the model is trained on the training set only
- 1 mark for stating that the testing set contains unseen cases
- 1 mark for explaining that testing accuracy estimates performance on new data or reveals overfitting
- 3.State[2 marks]
State two tasks that machine learning can solve.
Show mark schemeHide mark scheme
Model answer
Sorting items into categories, such as spam filtering. Predicting a number, such as a house price.
- 1 mark for stating one valid task
- 1 mark for stating a second valid task, such as grouping similar items, recommending items or spotting unusual cases
- 4.Outline[3 marks]
Outline the main steps of a machine learning workflow.
Show mark schemeHide mark scheme
Model answer
Define the problem, then collect and prepare data. Split the data, train a model and evaluate it on testing data. Finally deploy the model and monitor it.
- 1 mark for stating that the problem is defined and data is collected and prepared
- 1 mark for stating that the data is split, a model is trained and it is evaluated on testing data
- 1 mark for stating that the model is deployed and monitored
- 5.Discuss[3 marks]
Discuss why having a very large dataset does not guarantee a good model.
Show mark schemeHide mark scheme
Model answer
A large dataset may contain errors or missing cases, so quality matters as well as quantity. If it misses common cases, the model will perform badly on them. A model can also overfit, learning quirks instead of general patterns.
- 1 mark for stating that data quality matters as well as quantity
- 1 mark for explaining that data missing common cases leads to weak performance on them
- 1 mark for explaining that overfitting can occur whatever the dataset size

Practice this topic
10 quick-fire multiple-choice questions, easy to hard. Tap an answer to see if you're right and the worked explanation. (The written questions with mark schemes are under “Check your recall” above.)
0 right0 of 10 answered
Includes the 2 quick checks in the note above.
Easy[1 mark]
Show answer and explanation
Answer: B · Worked explanation
Medium[1 mark]
Show answer and explanation
Answer: D · Worked explanation
Medium[1 mark]
Show answer and explanation
Answer: C · Worked explanation
Medium[1 mark]
Show answer and explanation
Answer: B · Worked explanation
Medium[1 mark]
Show answer and explanation
Answer: A · Worked explanation
Hard[2 marks]
Show answer and explanation
Answer: C · Worked explanation
Hard[2 marks]
Show answer and explanation
Answer: A · Worked explanation
Hard[2 marks]
Show answer and explanation
Answer: B · Worked explanation