Skip to main content
SingaporeComputer ScienceSyllabus dot point

What is machine learning, and how does learning from data differ from a traditional programmed solution?

Explain what machine learning is, how a model learns from training data, and how it differs from rule-based programming

A focused answer to the H2 Computing outcome on machine learning fundamentals. Learning a model from data rather than coding explicit rules, training and inference, features and labels, and the role of data quality.

Generated by Claude Opus 4.88 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The answer
  3. Examples in context
  4. Try this

What this dot point is asking

SEAB wants you to explain what machine learning is, how a model learns from training data, and how this differs from traditional rule-based programming. The central idea is a reversal of the usual approach: instead of a programmer writing explicit rules, the system learns the rules from examples, building a model that can then make predictions on new data.

The answer

Rule-based versus learned

In traditional (rule-based) programming, a human writes explicit instructions: given inputs, follow these rules to produce an output. This works when the rules are known and stable.

In machine learning, the system is given many examples and learns the patterns itself, producing a model that maps inputs to outputs. No human writes each rule; the rules are inferred from data. This suits problems where the rules are too complex, varied or changeable to write by hand (recognising images, filtering spam, predicting demand).

Training and inference

Machine learning has two phases:

  • Training - the model learns its internal parameters from training data, adjusting them so its predictions match the known answers as closely as possible.
  • Inference (prediction) - the trained model is applied to new, unseen data to make predictions.

A model is trained once (or periodically retrained) and then used many times for inference.

Features and labels

The training data is described by:

  • Features - the input attributes the model uses (an email's number of links, a pixel's value, a house's size).
  • Labels - the correct output for each training example (spam or not, the digit shown, the house price), in supervised learning.

The model learns to map features to the right output.

Data quality, bias and generalisation

A model learns only from the data it sees, so data is decisive:

  • Quantity - too little data fails to capture the pattern reliably.
  • Quality and bias - unrepresentative or biased data makes the model learn that bias, performing unfairly or inaccurately on under-represented cases.

A good model generalises - it is accurate on new, unseen data, not just the training set. A model that merely memorises the training data (and fails on new data) is said to overfit.

Examples in context

Example 1. Recommendation systems. A streaming service predicts what you will watch next not from hand-coded rules but from patterns learned across millions of users' viewing histories. As tastes and the catalogue change, the model is retrained on fresh data - adapting in a way that fixed rules never could.

Example 2. Why biased data harms a model. A hiring model trained mostly on data from one group can learn that group's patterns and judge others unfairly, because it only knows what its training data showed. This illustrates that representative, unbiased data is not optional - it directly determines whether the model is fair and accurate.

Try this

Q1. State the key difference between rule-based programming and machine learning. [2 marks]

  • Cue. Rule-based programming has a human write explicit rules; machine learning learns the patterns (rules) from example data to build a model.

Q2. Define a feature and a label in a training dataset. [2 marks]

  • Cue. A feature is an input attribute used to predict; a label is the correct output for a training example.

Q3. What does it mean for a model to generalise well? [1 mark]

  • Cue. It makes accurate predictions on new, unseen data, not just the training examples (it has not overfit).

Exam-style practice questions

Practice questions written in the style of SEAB exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

Original6 marks(a) Explain the difference between a traditional rule-based program and a machine learning approach to a task such as recognising spam email. (b) Define training and inference. (c) Why might machine learning succeed where explicit rules struggle?
Show worked answer →

(a) A rule-based program uses explicit rules written by a programmer (for example, "if the subject contains 'free prize', mark as spam"). A machine learning approach instead learns patterns from examples: it is given many emails already labelled spam or not spam, and it builds a model that captures the statistical patterns distinguishing them, without a human writing each rule.

(b) Training is the process of learning the model's parameters from labelled (or unlabelled) training data. Inference (prediction) is using the trained model on new, unseen data to make a prediction (classify a new email as spam or not).

(c) Machine learning can succeed where rules struggle because spam is varied and constantly changing; no fixed set of hand-written rules can cover every case, and spammers adapt. A model learns subtle, combined patterns from data and can be retrained as spam evolves, generalising better than brittle explicit rules.

Markers reward the hand-coded-rules versus learned-from-examples contrast, correct training (learn from data) and inference (predict on new data) definitions, and ML generalising to varied/changing cases where fixed rules fail.

Original5 marks(a) Define the terms feature and label in a machine learning dataset. (b) Explain why the quality and quantity of training data strongly affect a model's performance, including the idea of bias in data. (c) What is meant by a model generalising well?
Show worked answer →

(a) A feature is an input attribute the model uses to make a prediction (for example, the number of links in an email, or a pixel value). A label is the correct output for a training example (for example, "spam" or "not spam") that the model learns to predict.

(b) A model learns only from the data it is given, so poor or insufficient data leads to a poor model. Too little data means patterns are not captured reliably; biased data (unrepresentative of real cases) makes the model learn that bias and perform unfairly or inaccurately on under-represented cases. Good performance needs enough representative, accurately labelled data.

(c) A model generalises well when it makes accurate predictions on new, unseen data, not just the training examples - it has learned the underlying pattern rather than memorising the training set (which would be overfitting).

Markers reward feature (input attribute) and label (correct output) definitions, data quality/quantity and bias affecting performance, and generalisation as accuracy on unseen data (not memorising).

Related dot points