Tutorial T-01 · Unit 1
What is Machine Learning?
The core idea behind the entire field, explained through a problem that classical programming cannot solve well. By the end of this tutorial you will be able to define machine learning precisely and recognise when it applies.
01 Learning Objectives
By the end of this tutorial you will be able to
- Define machine learning in your own words and explain how it differs from classical programming.
- State Tom Mitchell’s formal definition and identify its three components: task, experience, and performance measure.
- Recognise the three ingredients present in every learning system: data, model, and objective.
- Distinguish supervised from unsupervised learning at a conceptual level.
- Judge whether a given problem is well-suited to a machine learning approach.
02 Motivating Example
Imagine you have been asked to write a program that decides whether an email is spam. This is a classic problem, and the obvious approach is to write rules.
if email contains "free money" → mark as spam
if email contains "click here" → mark as spam
if sender is in blocklist → mark as spam
if email contains "unsubscribe" → mark as legitimate
This works for a while. Then reality intervenes:
- Spammers learn to write
fr33 m0neyandcl1ck here, and your keyword rules stop matching. - New senders appear every day, and your blocklist is always behind.
- A legitimate newsletter you subscribed to contains the word unsubscribe — and gets marked as spam.
- Your rules grow into thousands of lines, and nobody can explain why any single one exists.
The rules approach fails not because any individual rule is wrong, but because the problem changes faster than you can write rules to keep up with it.
The machine learning approach
Instead of writing rules, you give the computer thousands of emails already labelled spam or not spam, and let it work out the rules itself. That is the whole idea. The shift from writing rules to learning rules from examples is what machine learning is.
03 Concept Explanation
The most widely cited formal definition of machine learning comes from Tom Mitchell’s 1997 textbook:
A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T, as measured by P, improves with experience E.
— Tom M. Mitchell, Machine Learning (1997)
The definition is dense, so let us unpack it with the spam example:
- Task T
- Classifying an email as spam or not spam.
- Experience E
- A large set of emails, each already labelled as spam or not spam.
- Performance measure P
- The fraction of emails the system classifies correctly.
For a program to be learning, all three must be present and linked. If performance P does not improve as experience E grows, the program is not learning — it is just following rules.
The three ingredients of a learning system
Stripping away the formality, every machine learning system contains the same three components:
- Data — the examples the system learns from. This is what Mitchell calls experience.
- A model — a mathematical structure with adjustable parameters. The model is what does the learning.
- An objective — a precise definition of what “better” means. This is Mitchell’s performance measure, expressed as something the algorithm can optimise.
Every algorithm you will meet in this course — from linear regression in Module 2 to convolutional networks in Module 5 — is a specific combination of these three. Different algorithms differ in how they represent the model and what objective they optimise, but the underlying structure is always the same.
Classical programming versus machine learning
The clearest way to understand what is new about machine learning is to compare it with the classical approach you already know.
In classical programming, you write the rules and the computer applies them to data. The rules are the input; the answers are the output.
In machine learning, you provide the data and the answers, and the computer works out the rules. The rules are now the output, not the input.
This reversal — rules as output rather than input — is the single most important idea in this tutorial. It is worth reading twice.
Two broad categories
Machine learning is usually divided into two large categories, depending on what kind of data you have:
- Supervised learning — you have labelled examples. The system learns to map inputs to outputs. Spam filtering is supervised learning: every training email has a known label.
- Unsupervised learning — you have data but no labels. The system finds structure on its own. Grouping customers into segments based on purchasing behaviour, without being told what the segments should be, is unsupervised learning.
There is a third category, reinforcement learning, in which a system learns by interacting with an environment and receiving rewards. We will mention it in passing but the course focuses on the first two.
When is machine learning a good fit?
Machine learning is often described as a solution in search of problems. It is powerful, but it is not always the right tool. It tends to work well when:
- The problem is too complex to write rules for by hand, or the rules would be too numerous to maintain.
- There are patterns in the data, even if we cannot articulate what they are.
- The problem changes over time, so static rules would need constant rewriting.
- We have, or can obtain, examples to learn from.
It tends to be a poor fit when:
- The problem has clean, stable rules — use classical programming instead.
- There is no data to learn from, and none can be reasonably obtained.
- The cost of an unexplainable error is so high that a simple, auditable rule is preferable.
- The problem is fundamentally about reasoning or computation, not about finding patterns.
04 Visual Illustration
The diagram below contrasts the two approaches side by side. Read it slowly: the boxes on the left are the inputs, the boxes on the right are the outputs, and the difference between the two panels is where the rules come from.
05 Worked Example
Let us apply Mitchell’s definition to a concrete problem: predicting whether a student will pass a course.
Suppose a university has records for 200 previous students. For each student, the record contains their average hours of study per week, their attendance rate, and their prior GPA. It also records whether they ultimately passed the course.
We want to build a system that, given a new student’s study hours, attendance, and prior GPA, predicts whether they will pass.
Working through Mitchell’s definition
- Task (T): Classify a student as likely to pass or likely to fail, given their study habits and prior performance.
- Experience (E): The 200 historical student records, each with its features (study hours, attendance, prior GPA) and its known outcome (passed or failed).
- Performance measure (P): The fraction of predictions that turn out to be correct. If we predict that 100 students will pass and 87 of them actually do, our accuracy is 87%.
The three ingredients of the learning system map cleanly onto this problem:
- Data: 200 rows, each with three features and one label.
- Model: For a first attempt, we might use logistic regression — a model we will meet in Module 2 that produces a probability between 0 and 1.
- Objective: Minimise the number of incorrect predictions on the training data, or equivalently maximise accuracy.
Training the model means adjusting its internal parameters until the objective is as good as it can be. Once trained, we check the model on a fresh set of students it has never seen, to make sure it learned something general rather than memorising the training data.
What we have just described is the full lifecycle of a supervised learning project, compressed into three paragraphs. Everything else in this course is a refinement of these ideas: better models, better objectives, better ways of measuring whether the model has actually learned something useful.
A note on memorisation
A model that predicts perfectly on the training data but poorly on new data has not learned — it has memorised. This is called overfitting, and it is the single most common way machine learning projects fail. We will return to it in T-07 of this unit and again in Module 2, Unit 6.
06 Interactive Activity
Classify the problem
For each of the following problems, decide whether a machine learning approach is appropriate. For each one, ask yourself three questions:
- Is there a clear, stable set of rules that could be written by hand?
- Do we have (or can we obtain) examples to learn from?
- Do the rules change over time, or stay fixed?
| # | Problem | Your answer |
|---|---|---|
| 1 | Calculating income tax owed given a salary and deductions. | |
| 2 | Predicting which customers will cancel their subscription next month. | |
| 3 | Sorting a list of names alphabetically. | |
| 4 | Detecting fraudulent credit card transactions. | |
| 5 | Converting a temperature from Celsius to Fahrenheit. | |
| 6 | Translating English text into French. | |
| 7 | Finding the shortest route between two cities on a road network. | |
| 8 | Diagnosing a disease from a medical image. | |
| 9 | Recommending the next song a listener might enjoy. | |
| 10 | Checking whether a number is prime. |
Show suggested answers
1. Tax calculation — classical programming. The rules are stable, well-defined by law, and must be exactly reproducible. There is no pattern to discover.
2. Customer churn — machine learning. The reasons customers leave are complex and shifting. There is historical data with known outcomes.
3. Sorting — classical programming. Sorting is a solved computational problem. There is nothing to learn.
4. Fraud detection — machine learning. Fraudsters constantly change tactics, and the patterns are too subtle to encode as rules. There is plenty of historical labelled data.
5. Celsius to Fahrenheit — classical programming. A single arithmetic formula solves it perfectly.
6. Machine translation — machine learning. Language is too nuanced for hand-written rules, and large parallel corpora of translations exist.
7. Shortest route — classical programming. This is a graph problem with well-known optimal algorithms (Dijkstra’s, A*). Machine learning is not needed.
8. Medical diagnosis from images — machine learning. The visual patterns that distinguish disease from health are subtle and hard to articulate, but large labelled datasets exist.
9. Music recommendation — machine learning. Taste is personal, contextual, and changing. There is enormous behavioural data to learn from.
10. Primality testing — classical programming. A deterministic mathematical procedure solves this exactly.
The pattern should be clear: if you can write the rules, write the rules. Machine learning is for problems where the rules are unknown, unstable, or too complex to articulate — but where examples exist to learn from.
07 Self-Check Questions
Try each question before revealing the answer. If you get one wrong, re-read the section it refers to before continuing.
Question 1
Which of the following best captures what is new about machine learning, compared with classical programming?
Show answer
B. The reversal — rules as output rather than input — is the defining shift. The other options are either false or incidental.
Question 2
In Mitchell’s definition, a program learns from experience E with respect to task T and performance measure P if its performance at T, as measured by P, improves with E. For a system that predicts house prices from historical sales data, what is the performance measure P?
Show answer
C. The performance measure is the objective the system is trying to improve — typically the average difference between predicted and actual prices. Option A is the experience, option B is the task, and option D is neither.
Question 3
A team is building a system to detect whether a photograph contains a cat. They have 50,000 photographs, each labelled cat or not cat. Which category of machine learning does this problem fall into?
Show answer
A. The photographs are labelled, which makes this supervised learning. If the photographs were unlabelled and the goal were to group them by visual similarity, it would be unsupervised.
Question 4
True or false: if a model achieves 100% accuracy on its training data, it has definitely learned the underlying pattern.
Show answer
False. A model that memorises the training data will also achieve 100% accuracy on it — but perform poorly on new data. This is overfitting, and it is why we always evaluate models on data they have not seen during training.
Question 5
Which of the following is the strongest signal that a problem is not well-suited to machine learning?
Show answer
B. If the rules are simple and stable, classical programming is the better tool. Options A, C, and D are all signals that machine learning may be appropriate.
08 Practice Exercises
These exercises build fluency with the vocabulary and concepts from this tutorial. They are short by design. If any feel difficult, revisit the relevant section before moving on.
-
Identify the three components. For each scenario below,
state the task (T), the experience (E), and the performance measure (P)
in Mitchell's definition.
- A system that predicts tomorrow's rainfall from today's weather readings.
- A system that sorts incoming customer emails into “urgent” and “routine”.
- A system that recommends songs to a listener based on their past listening history.
-
Classify the problem. For each of the following, decide
whether it is better suited to classical programming or machine learning,
and give one sentence of justification.
- Converting a Fahrenheit temperature into Celsius.
- Predicting whether a customer will click on an advertisement.
- Checking whether a password meets a set of complexity rules.
- Diagnosing whether a photograph shows a benign or malignant skin lesion.
-
Match the terms. Match each term on the left with its
definition on the right.
Term Definition Feature What we want the model to predict Label A number inside the model that is adjusted during training Parameter An input variable the model uses Loss A measure of how wrong the model's predictions are -
True or false, with justification. State whether each
claim is true or false and give a one-sentence reason.
- Every system that improves over time is a machine learning system.
- A lookup table that stores the answer for every possible input is a model.
- If a program's performance at a task improves as it sees more data, it is learning in Mitchell's sense.
09 Problem Sets
Analytical problems
-
A hospital is considering two systems to help triage patients arriving in an emergency department. System A is a rule-based system built from a physician's decision protocol. System B is a machine learning system trained on five years of triage decisions made by experienced nurses.
(a) Which system is more likely to perform well on unusual cases the protocol was not designed for? Justify your answer. (b) Which system is more likely to explain why it made a particular decision? (c) If the hospital had only six months of triage data, how would your recommendation change?
-
Consider the following claim: “Any task that a human can perform can in principle be performed by a machine learning system.”
Give two distinct counterexamples. For each, explain what specifically about the task makes it unsuitable for a learning approach.
-
The performance measure P in Mitchell's definition is chosen by whoever is building the system. Describe a scenario in which two reasonable people would disagree about what P should be for the same task, and explain what practical consequences that disagreement would have.
Technical problems
-
Write pseudocode for a system that learns to predict a student's exam score from hours studied. Your pseudocode should include all four steps of the training loop from T-05 and should identify which variables are features, which are labels, and which are parameters.
-
The following table records four training examples for a system that predicts whether a customer will make a purchase.
Age Previous purchases Made a purchase? 25 0 No 42 8 Yes 31 2 No 55 12 Yes (a) Identify the features and the label. (b) A model makes the following predictions on this data: No, Yes, Yes, Yes. Compute the accuracy of the model. (c) Is this dataset sufficient to train a reliable model? Explain your reasoning.
-
A learning system stores its knowledge as a set of 47 numbers. If you replaced all 47 numbers with random values, would the resulting program still be a model? Would it still be learning? Justify your answers with reference to the definition of machine learning from this tutorial.
Theoretical questions
- Why does Mitchell's definition require that performance improve with experience? What would be lost if the definition were weakened to simply “performance correlates with experience”?
- Classical programming is sometimes described as encoding knowledge explicitly and machine learning as encoding knowledge implicitly. What does this distinction mean, and is it a useful way to characterise the difference between the two approaches?
- Every machine learning system contains a model, and every model has parameters. Is it possible to imagine a learning system whose parameters are not numbers? If so, what would such a system look like, and would it still fit Mitchell's definition?
- The tutorial claims that machine learning is not always the right tool for a problem, even when a learning system could in principle be built. What kinds of reasons would justify choosing a simpler non-learning approach for a problem that machine learning could handle?
10 Discussion and Projects
Discussion questions
- A news article claims that a machine learning system has “learned to detect lies with 85% accuracy.” What questions would you want answered before deciding whether to believe this claim?
- A university considers replacing its rule-based plagiarism detection system with a machine learning one trained on past cases of confirmed plagiarism. What are the potential advantages? What concerns would you raise?
- Some computer scientists argue that the term “machine learning” is misleading because these systems do not learn the way humans do. Do you think the terminology is problematic? If so, what would you change it to?
- Consider a system that recommends which candidates to interview for a job. The system is a machine learning model trained on ten years of hiring data. Discuss: should this system be built at all? What conditions would need to be met for it to be acceptable?
Case study: the Amazon hiring algorithm
Case study
In 2014, Amazon began developing an automated system to review job applications and identify the strongest candidates. The system was trained on ten years of the company's own hiring decisions — who applied, who was interviewed, and who was ultimately hired.
By 2015, the system had begun to exhibit a serious problem. It consistently penalised resumes that contained the word “women's”, as in “women's chess club captain”. It downgraded graduates of two women's colleges. The model had learned from the historical data that Amazon had historically hired far more men than women into technical roles, and it had concluded that being male was a positive predictor of suitability.
Amazon attempted to neutralise the problem by editing the training data to remove gender-related terms. But the underlying pattern was embedded in many other features that correlated with gender, and the engineers could not reliably remove all of them. The project was abandoned in 2017.
Analysis questions:
- In Mitchell's terms, what were the task, experience, and performance measure of the Amazon system?
- Was the system technically working as designed? If so, what exactly was wrong with it?
- The system was trained on ten years of historical hiring decisions. Under what circumstances would this be an appropriate source of training data? Under what circumstances would it not be?
- Amazon's engineers attempted to fix the problem by editing the training data. Why did this not work?
- What would you have advised the team to do differently, either at the start of the project or at the point the problem was discovered?
Critical-thinking activity: evaluating an AI claim
Activity
Find a recent news article or press release that describes a machine learning system being used or developed for a real-world application. Write a one-page critical evaluation of the claim, addressing:
- What is the task the system performs?
- What data was it trained on, and how was that data collected?
- What is the performance measure being reported? Is it the right measure for this problem?
- What failure modes from T-07 might this system be vulnerable to?
- What would you want to know before trusting this system in the way the article implies?
The goal is not to be cynical but to be precise. Many AI claims are true and useful; the skill is telling which ones.
Homework assignment
Assignment
Choose a real-world product or service that uses machine learning. It can be something you use yourself (a recommendation system, a voice assistant, a photo app) or something you have read about. Write a 1,000-word analysis covering:
- What the system does, and who it is for.
- An identification of the task, experience, and performance measure in Mitchell's terms.
- An informed guess at what the features and labels might be.
- One plausible failure mode and its consequences.
- A brief judgement on whether machine learning is the right approach for this problem, or whether a non-learning system would be preferable.
Cite at least two sources (articles, documentation, or papers). The analysis should demonstrate familiarity with the concepts from T-01 and T-05.
Mini-project: build a decision tree by hand
Mini-project
The following dataset records whether to play tennis on fourteen days, based on four weather features.
| Day | Outlook | Temperature | Humidity | Wind | Play? |
|---|---|---|---|---|---|
| 1 | Sunny | Hot | High | Weak | No |
| 2 | Sunny | Hot | High | Strong | No |
| 3 | Overcast | Hot | High | Weak | Yes |
| 4 | Rain | Mild | High | Weak | Yes |
| 5 | Rain | Cool | Normal | Weak | Yes |
| 6 | Rain | Cool | Normal | Strong | No |
| 7 | Overcast | Cool | Normal | Strong | Yes |
| 8 | Sunny | Mild | High | Weak | No |
| 9 | Sunny | Cool | Normal | Weak | Yes |
| 10 | Rain | Mild | Normal | Weak | Yes |
| 11 | Sunny | Mild | Normal | Strong | Yes |
| 12 | Overcast | Mild | High | Strong | Yes |
| 13 | Overcast | Hot | Normal | Weak | Yes |
| 14 | Rain | Mild | High | Strong | No |
Your task. Without using any software, build a decision tree that classifies each day correctly. Then answer:
- What is your tree's structure? Write it out as a set of if-then rules.
- Which feature did you choose for the first split, and why?
- What would this tree predict for a day that is Sunny, Mild, Normal, Weak?
- Is there a day in the training data your tree gets wrong? If so, why?
- What does this exercise tell you about what a decision tree is actually doing?
There is no single correct tree. The purpose is to work through the process of building a classifier by hand, which is what a decision tree algorithm does automatically. You will meet the formal algorithm in Module 3.
11 Summary
Key takeaways from this tutorial
- Machine learning is the practice of building systems that improve at a task through experience, rather than through explicitly programmed rules.
- Mitchell’s definition gives us three components: a task T, an experience E, and a performance measure P. All three must be present for a system to be learning.
- Every learning system contains data, a model, and an objective. Different algorithms differ in how they represent the model and what they optimise.
- Classical programming takes rules and data as inputs and produces answers. Machine learning takes data and answers as inputs and produces rules.
- Supervised learning uses labelled examples; unsupervised learning finds structure in unlabelled data.
- Machine learning is not always the right tool. If the rules are simple, stable, and easy to write, write them.
12 Further Reading
The following sources expand on the ideas in this tutorial. None are required reading, but each is worth returning to as the course progresses.
-
Mitchell, T. M. (1997). Machine Learning.
McGraw-Hill. Chapter 1.
The source of the formal definition used in this tutorial. Chapter 1 is short and accessible. -
Domingos, P. (2012). “A Few Useful Things to Know
About Machine Learning.” Communications of the ACM, 55(10),
78–87.
A widely cited article that pairs well with this tutorial. It offers a practitioner’s view of what matters and what does not. -
Jordan, M. I., & Mitchell, T. M. (2015). “Machine
learning: Trends, perspectives, and prospects.” Science,
349(6245), 255–260.
A broader survey of the field, useful for understanding where machine learning sits within computer science and beyond. -
Google Developers. Machine Learning Crash Course.
A free online resource with a gentler, more applied introduction. Useful as a companion to the first few units.
Next up
T-02 traces the history of artificial intelligence, from Turing’s foundational question through two AI winters to the statistical turn that produced modern machine learning. It provides the context for the ideas you have just read.