Machine Learning · Week 1 · Lecture 1 · Introduction to Machine Learning · Interactive sheet · Beginner

The Introduction to Machine Learning Blueprint

Machine learning is a computer learning from data and getting better with experience, instead of following rules a programmer wrote by hand. Whether the data has labels, rewards or neither decides which kind of learning you use. 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), what a percentage and an average are, and the habit of sorting things into groups, which you already do every day. No programming or maths beyond that is needed.

3
fields under Data Science
4
fruit features
2
types of supervised
5
RL components
2¹⁰ = 1,024
cells for 10 features
1959
'machine learning' named
01

Sorting fruit: the challenge that introduces machine learning

A factory belt carries apples, bananas, oranges and mangoes, and a machine must put each one in the right bin: the lecture uses this one scenario to explain Data Science and its 3 fields.

The Data Science umbrella · click a field

3
fields: DM · ML · AI
4
features per fruit
timeline · click a year
1957 1959 1997 1998 2015 2018

Why this matters

Writing a rule for every fruit by hand breaks the moment a new fruit, a bruised apple or a green banana arrives. A system that learns from data can fix its own mistakes. The same idea that sorts fruit also filters spam, recommends films and steers self-driving cars.

02

Walk one fruit through Data Mining, Machine Learning and AI

Follow one mango from the camera to the right bin, stage by stage: drag the scrubber, press play or click a bead, and watch what the system knows at each step.
Data Mining Machine Learning AI
stage 1 of 6100%
stage scrubbercollect
Data Science = Data Mining (patterns) + Machine Learning (models) + AI (decisions).
Data Science

fruit types known
0
labelled examples
0
mistakes corrected
0
fruits sorted
0
Quick check
The model calls the mango an “apple”. A worker writes the correct label and the model gets it right next time. Which field is doing the learning here?
Learning from a past mistake and doing better next time is exactly what Machine Learning means. Data Mining only discovers patterns in existing data; AI is the part that decides and acts.
03

The ideas that make it work: features, labels, patterns and experience

Three small demos built on the same 48 measured fruits: how many features you use, whether the data has labels, and which patterns hide in it.
Idea 1 · features

More features, fewer mix-ups

features used1
0 %fruits named correctly

Idea 2 · labels

With or without the answer column

Idea 3 · patterns

What data mining discovers

Experience ties it together: the more labelled examples a model sees, the better its guesses become. Section 04 lets you add experience one example at a time and watch the score climb.

Quick check
Using only colour, some mangoes are called oranges. Adding shape, size and texture fixes most of them. Why?
A mango and an orange can share a colour, but differ in shape and texture. Each well-chosen feature gives the model another way to separate the groups.
04

The defining rule: learn from data, not from explicit programs

A hand-written program follows fixed rules; a machine learning model gets better as it sees more examples. Drag the slider to add experience and compare both on the same 40 test fruits.
performance P (test fruits right) vs experience E (examples per fruit type)100%
experience E: labelled examples per fruit type1
explicit program
0 %
rules written by hand
vs
learned model
0 %
learned from examples
Program: data + rules → answers
ML: data + answers → rules (model)
Mitchell: learns ⇔ P on T improves with E

The definition. Machine learning learns from data and improves its performance without being explicitly programmed. Here: task T = name the fruit, experience E = labelled examples, performance P = share of test fruits named correctly.

Quick check
A spam filter's rules were typed in by an engineer in 2010 and never change. Is it machine learning?
Machine learning means performance P improves with experience E. Fixed hand-written rules never improve, however many emails pass through them.
05

Classify, regress or cluster: decide it by hand and by eye

First name one new fruit by hand with three labelled examples, then use the decider: two questions about the data tell you whether a task is classification, regression or clustering.

Worked example by hand: name a new fruit from three labelled ones

Press Next step.

Two features, each scored 0 to 10. To compare the new fruit with an example, take the gap on colour and the gap on size (always positive) and add them. The smallest total wins, and the new fruit copies that example's label.

type = labels? no → clustering · yes → category or amount? → classification | regression
what the model learns100%
Quick check
A shop wants to predict how many umbrellas it will sell tomorrow from past sales and the weather forecast. Which task is it?
Past sales give labelled examples (supervised), and the answer is “how many”, a number on a scale, so it is regression.
06

Where the rewards add up: State, Action, Reward and the cumulative reward

In reinforcement learning an agent acts, gets a reward or a penalty, and tries to make the cumulative reward as large as possible: each bar below is one moment of a child learning to ride a bicycle.
SState AAction RReward S'Next State πPolicy
100%
reward (+)penalty (−)click a bar for its arithmetic
click a bar

The S, A, R, S' of that moment and the running total appear here.

Rewards vs penalties

Cumulative reward

Worked example: the 6 steps of learning to ride a bicycle

State (S): the child sits on the bike, which is still and upright
S = “stopped, balanced”
Action (A): the child pushes the pedals and turns the handlebars a little
A = “pedal + small steer”
Reward (R): staying up and moving feels good; wobbling or falling hurts
R = + for balance and progress, − for a fall
Next State (S'): the bike is now moving, maybe leaning; this becomes the new S
S' = “moving slowly, leaning left” → next S
Policy (π): the child's growing sense of what to do in each situation
π: “leaning left → steer gently left and keep pedalling”
Learning Process: the child mixes exploration (trying new moves) with exploitation (repeating moves that worked)
many rides → policy improves → cumulative reward grows

These are the 5 components (S, A, R, S', π) plus the learning process that ties them together. The environment is the bike, the road and gravity.

Quick check
After practice the child always uses the moves that worked before and never tries anything new. What is the child doing?
Using what already works is exploitation; trying new actions to discover better ones is exploration. A good learner balances both.
07

The family: supervised, unsupervised, reinforcement and transfer learning

Four ways a machine can learn, told apart by what the data gives it: answers, nothing, rewards, or a model someone already trained. Click a row to compare, then load it into the fruit walker.
learning type

Pick a row above.

Transfer learning: reuse, then fine-tune

pre-trained model
layers to fine-tune (from the top)1
Quick check
A store has thousands of customer records but no column saying which “type” of customer each one is. It wants to find groups of similar customers. Which learning type fits?
There are no labels, so it cannot be supervised. Grouping similar examples without answers is clustering; people can name the groups afterwards, just as with the fruits.
08

The cost and the limits: the curse of dimensionality

Every feature you add is one more dimension, and the space to fill grows much faster than your data: this is the curse of dimensionality. Move the sliders and watch its 4 problems appear.
number of features (dimensions)10
ranges per feature2
examples in the dataset1,000
cells = rangesfeatures = 2¹⁰ = 1,024
1 · empty cells (sparsity)
2 · comparisons per new item
3 · examples per cell (overfitting)
4 · far ÷ near distance gap
distance gap (far − near) ÷ near, 120 random points · current setting in red100%
1

Increased sparsity

The data is spread so thin that most combinations of feature values have no example at all.

2

Higher computational cost

More features mean more numbers to store and compare for every example.

3

Overfitting risk

With many features and few examples, the model memorises noise instead of the real pattern.

4

Distance-based issues

In k-NN or clustering, all points appear equally distant, so “nearest” loses its meaning.

Quick check
You split every feature into 2 ranges. Going from 10 features to 11, what happens to the number of cells your data must fill?
Each added feature splits every existing cell into 2, so the count doubles: 2¹⁰ = 1,024 becomes 2¹¹ = 2,048. Set the first slider to 11 to see it.
09

Apply it yourself: choose the right learning type and set up Anaconda

A five-question checklist turns any new problem into a learning type; try it on six scenarios, then prepare your computer for the tutorial with Anaconda.

The checklist

What decision or prediction do you want?
e.g. “which fruit?”, “how much?”, “which group?”, “what to do next?”
Does every example come with the right answer (a label)?
no → unsupervised: clustering
If yes: is the answer a category or an amount?
category → classification · how much / how many → regression
No fixed answers, but an agent acts and gets rewards?
→ reinforcement learning (S, A, R, S', π)
Does a pre-trained model for a similar task exist?
yes → transfer learning: reuse it and fine-tune a few layers

Try it: pick a type for each scenario

Tutorial preparation: install Anaconda

Download the installer for your system
docs.anaconda.com/anaconda/install/
Run it with the default options
it installs Python, Jupyter and common data libraries
Open “Anaconda Prompt” (Windows) or a terminal (macOS / Linux) and check
conda --version → prints a version number
Start a notebook and run the snippet on the right
jupyter notebook → New → Python 3
# your first classifier: 4 fruits, 2 features (colour, size)
from sklearn.neighbors import KNeighborsClassifier

X = [[1, 4], [8, 9], [4, 5], [6, 6]]   # features
y = ["apple", "banana", "orange", "mango"]   # labels

model = KNeighborsClassifier(n_neighbors=1)
model.fit(X, y)                    # learn from labelled data
print(model.predict([[2, 4]]))     # → ['apple']

The same nearest-example idea you did by hand in section 05, in six lines of scikit-learn.

Quick check
You want to sort photos of plant leaves into “healthy” or “diseased”, you have only 300 labelled photos, and a pre-trained image model exists. What is the most sensible plan?
The answer is a category (classification), the dataset is small, and a pre-trained image model exists: reuse it and fine-tune a few layers instead of starting from nothing.
10

From Samuel's checkers to BERT: a short history of machine learning

Each point is a milestone behind one idea of this lecture; the line counts how many of the lecture's ideas were in place by that year. Click a point for the story.
lecture ideas in place, 1957–2018100%
click a point

Before vs after learning from data · tap a card to flip

Quick check
Samuel's 1959 checkers program is a classic example of machine learning. Why?
Its performance (winning games) improved with experience (games played): Mitchell's later definition fits it exactly.
11

Where machine learning is used today

From the fruit belt to the motorway, each application below mixes the learning types of section 07; the chips show which ones.
Quick check
A self-driving car must recognise stop signs in camera images. Which learning type does that part mostly use?
Recognising a sign is a category answer learned from labelled images (classification); reusing a pre-trained image model such as ResNet saves time. Deciding how to drive can use reinforcement learning.
12

Key takeaways

Seven sentences to remember from Lecture 1; click each one for the evidence and the section to revisit.
In the fruit scenario: mining discovers “apples are usually red and smooth”, ML learns from the mango mistake, AI answers “Which fruit is this?” and sorts it. Sections 01–02.
Mitchell (1997): it learns if performance P on task T improves with experience E. Section 04 shows the learned model overtaking fixed rules.
4 fruit features: color, shape, size, texture. The “Fruit Type” column is the label. Section 03.
Spam (1), Not Spam (0) and Cat (1), Dog (2), Bird (3), Fish (4) are classification; an electricity bill or products sold are regression. Section 05.
Remove the Fruit Type column and the fruits can still be grouped by their 4 features. Sections 03 and 05.
The bicycle example ends with exploration vs exploitation (section 06). ResNet and BERT are fine-tuned by updating only a few layers (section 07).
2¹⁰ = 1,024 cells for 10 features split in 2. Four problems: increased sparsity, higher computational cost, overfitting risk, distance-based issues. Section 08.
13

Check your understanding

Five questions with instant feedback and every answer explained; score 4 or more and the stamp is yours.
0 / 5
■ STAMPED · INTRO TO ML BLUEPRINT · APPROVED
14

Glossary

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