Machine Learning · Topic 1 · Introduction to Machine Learning · Beginner · Interactive sheet

The Introduction to Machine Learning Blueprint

Machine learning lets a computer find its own rules from examples instead of following rules a person wrote. It learns from answers, from patterns, or from rewards, and it is always judged on examples it has never seen. Every number on this page is clickable. Every underlined term has a definition.

Before you startHow to read a table of data (rows are examples, columns are measurements, like a spreadsheet), how to read a dot on a graph with two axes, and percentages. Having seen Linear Regression helps but is not required.

1959
‘machine learning’ named
3 + 1
ways to learn
80 / 20
train / test split
70,000
MNIST digits
10d
boxes for d features
01

Rules nobody can write down

Some tasks are easy for people but almost impossible to describe as step-by-step rules; machine learning lets the computer find the rule from examples instead.

Spot the spam: one hand-written rule, or a learned one?

1959
Samuel’s checkers program
E · T · P
Mitchell’s definition, 1997
10 / 10
learned rule, left demo
3 + 1
ways to learn

The headline

“Machine learning is the field of study that gives computers the ability to learn without being explicitly programmed” is the usual summary of Samuel’s idea. Instead of writing the rule, you collect data, describe it with features, and let a model learn the rule.

timeline · click a chip
1950Turing: learning machines 1959‘machine learning’ 1986neural networks learn 1997Mitchell’s definition 2012deep learning wins 2016AlphaGo
02

Walk one example through the whole process

Follow a fruit-sorting machine from the first question to its first real prediction: drag the scrubber, press play or click a stage bead.
apple (label) orange (label) learned rule / test example
stage 1 of 7100%
stage scrubberask
Rule of the walk: learn on 16 fruits, judge on the 4 it never saw.
stage

training rows
0
test accuracy
–
Quick check
Why does the walk keep 4 of the 20 fruits out of training?
The test fruits stand in for the future. If the rule only works on the fruits it learned from, it has memorised them; the hidden 4 show whether it really learned what apples and oranges look like.
03

Three ways a machine can learn

Learn from examples that come with answers, find groups in examples without answers, or learn by trial and error from rewards: one demo and one control each.
supervised

1 · Learn from answers

In supervised learning every example has a label. Give the learner more labelled fruits and watch its rule (red line) settle.

labelled fruits seen4
unsupervised

2 · Find groups without answers

In unsupervised learning nobody says who is who. k-means sorts 15 shoppers into k groups by how often and how much they buy.

number of groups k3
reinforcement

3 · Learn from rewards

In reinforcement learning an agent acts and gets a reward: +10 at the goal, −1 per step. Arrows show what it currently thinks is best in each square.

steps taken in each episode (shorter is better)
Quick check
A shop has thousands of customer records but no information about “types” of customer. Which idea fits?
With no labels to copy and no rewards for actions, the machine can still notice which customers behave alike and group them, exactly what k-means did in card 2.
04

The golden rule: judge on unseen data

A model is only useful if it works on new cases, so its score on hidden test data counts, not its score on the training data; slide from a cautious model to one that memorises.

Predict pass or fail from hours of revision

passedfailedtest student predicted wrongly
how closely the model follows the training data
seen students
new students
error = wrong ÷ checked · accuracy = 1 − error

The rule. Learn from the training data, choose settings without peeking at the test data, and look at the test score once, at the end. A model that is too simple underfits; one that remembers every example overfits.

Quick check
A model is right 100 % of the time on its training data but only 60 % on new data. What happened?
A big gap between the seen and the unseen score is the sign of overfitting. Move the slider to the far right above: training error 0 %, test error up.
05

Nearest neighbour, by hand and by eye

The simplest learner of all, nearest neighbour, labels a new example by copying the answer of the most similar known example, where “similar” means a small distance between feature values.

Worked example by hand: three known fruits, one new one

known: A (2, 8) apple · B (6, 2) orange · C (3, 6) apple · new N (5, 4)
Press Next step. Each fruit is (size, redness), both on a 0–10 scale.

For each known fruit: subtract the sizes, subtract the rednesses, square both differences (multiply each by itself, so minus signs disappear), add them, then take the square root. The smallest result is the nearest neighbour.

distance = √( (weight difference)² + (redness difference)² ) √ and ²
neighbours asked (k)
prediction
16 training fruits · the new fruit (★) and lines to its nearest neighbours100%
rankfruitweightrednessdistance
Quick check
Why does this page measure weight in tens of grams before computing distances?
Distance adds up the squared differences. If one feature has much bigger numbers, it decides the distance on its own. Rescaling puts both features on a similar 0–10-ish range.
06

Where 70,000 examples add up

MNIST, the classic first dataset of handwritten digits, broken down by class and by split; every total below is added up from the per-digit counts.
100%
click a bar

The arithmetic for that bar appears here.

Training vs test

Features per picture

Each pixel is one feature: a number from 0 (white) to 255 (black ink).

Quick check
The digit 1 has the most training pictures and the digit 5 the fewest. Is that a problem for learning?
Each digit has between about 9 % and 11 % of the pictures. Small differences like this are normal; trouble starts when one class is very rare, say 1 in 1,000.
07

Four ways to learn, side by side

The kinds of learning differ in what the machine is given: answers, no answers, rewards, or a head start from another task; click a row for an example and a demo.
kindwhat it is givenfeedbacktypical questionbeginner method
kind of learning

Pick a row above.

Two families you will meet later. Self-supervised learning makes its own labels from raw data (hide a word, predict it) and is how large language models are pre-trained. Semi-supervised learning mixes a few labelled examples with many unlabelled ones.

Quick check
A hospital has only 200 labelled skin photos, and a free model already trained on millions of everyday photos. What is the sensible start?
The pretrained model already knows edges, textures and shapes. Transfer learning keeps that knowledge and only adapts the last part to the new task, which works with far fewer labelled examples.
08

The limit: the curse of dimensionality

Every extra feature multiplies the number of places an example can land, so the same amount of data spreads thinner and thinner: the curse of dimensionality.
number of features d2
steps per feature (e.g. low / medium / high = 3)10
examples you have1,000
30 examples · 1 feature
the same 30 examples · 2 features
boxes to fill
examples per box
boxes left empty
examples for 5 per box

What people do about it. Keep only features that matter (feature selection), squeeze many features into a few (dimensionality reduction), collect more data, or use models that look for simple structure. The name comes from Richard Bellman (1957).

Quick check
You keep 1,000 examples but go from 2 features to 6 (10 steps each). What happens to the data?
Boxes go from 10 × 10 = 100 to 10 multiplied six times = 1,000,000. 1,000 examples cannot fill a million boxes: almost every box is empty.
09

Apply it to your own problem

Answer three questions to pick the kind of learning, then follow the same seven steps every time; the code template follows your answers.

Which kind of learning?

Does the program act and get points for good results?
Do your examples come with the right answers (labels)?
Is there a model already trained on a similar, bigger task, and you have few labels?

The seven steps · click or reveal

Ask one clear question and decide what “good” means
“Is this email spam?” · success = share of emails sorted correctly
Collect examples (and labels, if supervised)
rows = examples · columns = features · one column = label
Choose and clean the features; put them on similar scales
weight → tens of grams · fill or drop missing values
Split before you learn anything
about 80 % training · 20 % test, picked at random
Train a simple model first
e.g. nearest neighbour or k-means · it sets the baseline to beat
Test once on the hidden data
test accuracy, not training accuracy, is the score you report
Use it, and keep checking it
the world changes: retrain when new data looks different
template · Python with scikit-learn (the most common beginner library)

        

Lines in red change with your answers. You do not need to run the code to follow this page; it shows that the seven steps map onto a few lines.

Quick check
At which point in the seven steps should you look at the test data?
Every time you peek at the test data and adjust the model, the test data stops being “unseen”. Keep it locked away until the end, then measure once.
10

From hand-written rules to learned rules

Seventy years of milestones, one lane per kind of learning; click a point for the story (the red point is where the field got its name).
milestones 1950–2018 · lanes: general · supervised · unsupervised · reinforcement · transfer100%
click a point

Before → after · tap a card to flip

Quick check
What is the main change from a rule-based program to a machine-learning program?
Both kinds of program end up applying a rule. The difference is where the rule comes from: an expert’s head, or a pattern found in data.
11

Where machine learning is used today

You probably used several machine-learning systems before breakfast; click each row to see which kind of learning sits behind it.
Millions of emails or card payments marked “spam / fine” or “fraud / fine” are the labelled examples. The model learns which combinations of clues give a case away, and it is retrained as tricksters change their tactics.
Shops group customers who behave alike without being told what the groups are, and suggest what similar people bought (“customers who bought this also bought…”). Recommendation systems also mix in supervised learning from ratings and clicks.
Models trained on labelled scans flag eye disease, skin cancer or broken bones for a doctor to check. Because labelled scans are scarce, these models usually start from a model pretrained on everyday photos: transfer learning.
AlphaGo learned Go partly by playing itself and being rewarded for wins. Reinforcement learning is also used to teach robot arms to grasp and to tune the cooling of data centres, wherever an agent can try actions and receive a score.
Large language models are first trained on huge amounts of text by predicting hidden words (self-supervised), then adapted to answering questions or translating: transfer learning on a grand scale. Human feedback is often added with reinforcement learning.
Factories and networks learn what “normal” sensor readings or traffic look like, without labels, and raise an alarm when something does not fit any usual group (anomaly detection).
Quick check
A music app groups listeners with similar tastes without anyone naming the groups. Which kind of learning is that?
No labels are given and no rewards are handed out: the app finds groups of listeners who behave alike, which is unsupervised learning (clustering).
12

Key takeaways

Seven sentences to remember; click each for the evidence and the section it comes from.
Samuel (1959) named it; Mitchell (1997) defined it: a program learns if its performance P on a task T improves with experience E. Section 01.
Two flavours: classification (which group? apple or orange) and regression (how much? a price). Sections 02 and 03.
k-means grouped 15 shoppers; the corridor agent found the shortest path from +10 and −1 rewards alone. Section 03.
It is the usual choice when labels are few and a model trained on a bigger, similar task exists. Sections 07 and 09.
A fruit becomes (weight, redness); an MNIST digit becomes 784 pixel values. Distances only make sense when features use similar scales. Sections 05 and 06.
Training error can reach 0 % by memorising; test error is the honest score. Split about 80 / 20 and look at the test data once. Sections 04 and 09.
With 10 steps per feature, d features give 10 multiplied by itself d times boxes to fill. Keep the features that matter. Section 08.
13

Check your understanding

Five questions with instant feedback and every answer explained; click a dot to jump to a question.
0 / 5
■ STAMPED · ML BLUEPRINT · BEGINNER · APPROVED
14

Glossary

Every term used on this page, in plain words; type to filter and click a term to open its definition.