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

The Introduction to Machine Learning Blueprint

Machine learning is a program that learns from data and improves its performance without being explicitly programmed. From sorting fruit to self-driving cars, what changes is only the data, the feedback it gets and how many features it must cope with.

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 an average is, and how to plot two numbers as a point on a graph. No programming is needed for this page; section 09 sets up the tools for the tutorial.

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 packing plant wants a machine that sorts apples, bananas, mangoes and oranges without a person checking each one, and answering that one request needs all 3 fields under the Data Science umbrella.

The Data Science umbrella · click a field

DATA SCIENCE Data Miningdiscovers patterns Machine Learningbuilds models AImakes intelligentdecisions
Data Science uses Data Mining to discover hidden patterns, Machine Learning to build models, and AI to make intelligent decisions. Click a circle for its job in the fruit plant.
3
fields, one umbrella
4
features per fruit
1959
'machine learning' named
1997
formal definition (T, E, P)

Why fruit?

The same three steps run a self-driving car: mine camera data for patterns, learn a model that recognises a pedestrian, and let AI decide to brake. Fruit is simply small enough to follow every step by hand.

milestones on this page · click a chip
02

Walk one fruit through Data Mining, Machine Learning and AI

Follow one mango from the moment it lands on the belt until a robot drops it in the right bin: drag the scrubber, press play or click a stage bead.
raw data Data Mining Machine Learning AI
stage 1 of 7100%
stage scrubberarrive
Data Mining describes the past, Machine Learning learns from it, AI acts on it.
raw data
A fruit arrives

features
0 / 4
P(mango)
–
Quick check
The model called a mango an apple, a worker corrected it, and next time it gets mangoes right. Which field did the improving?
Learning from past sorting mistakes is the lecture's example of Machine Learning: nobody rewrote the rules, the model changed itself from the corrected example. Data Mining only describes patterns, and AI is the part that sees and sorts.
03

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

Three small demos: features and labels are columns of a table, a pattern is a rule hidden in those columns, and experience is what makes performance grow.
idea 1 · features and labels

Same table, with and without the answer

idea 2 · patterns

'Apples are usually red and smooth'

rule: redness ≥6
idea 3 · experience (T, E, P)

Performance P improves with experience E

corrected examples E10
Quick check
In Mitchell's definition, what is E for the fruit-sorting machine?
T is the task (sorting fruit), P is the performance measure (percentage sorted correctly) and E is the experience: the examples, including corrected mistakes, that it learns from. It learns if P improves as E grows.
04

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

A programmer writes 'if redness ≥ 0.60 it is an apple'; a learner works the cut-off out from labelled examples, so change the lighting and see which one keeps sorting correctly.

Apples vs mangoes on a redness scale

applemangohand-written rulelearned rule
explicitly programmed
learned from data
lighting change (camera shift)0.00
labelled examples the learner sees10
hand-written
–
vs
learned
–
programming: Data + Rules → Answers
machine learning: Data + Answers → Rules
learned cut-off = (mean apple + mean mango) ÷ 2
Quick check
The plant installs brighter lamps and every fruit looks 0.2 redder. What keeps the sorting accurate?
The fixed rule 'redness ≥ 0.60' now calls many mangoes apples. The learner recomputes its cut-off from new labelled examples and moves with the data. Set the lighting slider to +0.20 above to see it.
05

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

Supervised learning has 2 types (classification and regression); with no labels you cluster instead, so work through the nearest-neighbour example by hand, then let the calculator do it for any fruit.

Worked example by hand: label a new fruit by its nearest neighbour

New fruit X: size 5, redness 7. Three labelled fruits are on the table. Which one is closest?

Press Next step to measure the first distance.

Distance between two points: subtract the sizes, subtract the rednesses, square both, add them, take the square root. The fruit with the smallest distance lends X its label.

d = √((size₁ − size₂)² + (red₁ − red₂)²) · keep the k nearest → vote, average or group
task
neighbours k3
predicted label
–
13 labelled fruits · size vs redness100%

Click anywhere on the plot to place the new fruit there.

Decide the task: the lecture's examples

Quick check
The 3 nearest neighbours of a new fruit cost RM 1.20, RM 1.50 and RM 1.20. What does 3-nearest-neighbour regression predict?
Regression predicts a continuous value, so the neighbours' prices are averaged: (1.20 + 1.50 + 1.20) ÷ 3 = 3.90 ÷ 3 = 1.30. A majority vote is what classification does with labels.
06

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

In reinforcement learning an agent acts in an environment, collects positive and negative rewards and tries to maximise the long-term cumulative reward: click a bar to see how a child's bicycle ride adds up.
100%
positive rewardnegative rewardcumulative reward after the step
click a bar

The arithmetic for that step appears here.

Gains vs losses

Cumulative reward

Worked example: a child learning to ride a bicycle, in 6 steps

State (S): the situation right now
sitting on the bike, wobbling slightly, speed low
Action (A): what the agent chooses to do
pedal, steer left or right, lean, or brake
Reward (R): the feedback from the environment
stays balanced → positive · falls over → negative
Next State (S'): where the action led
riding steadily, or lying on the ground
Policy (π): the strategy that picks an action in each state
'when wobbling to the left, steer slightly left and keep pedalling'
Learning Process: exploration and exploitation
try new moves to discover better ones, use the moves that already work · the goal: maximise the cumulative reward

The first five steps are the 5 components S, A, R, S', π. The sixth is how the policy gets better: by exploring and exploiting over many rides.

Quick check
A ride earns +1, −5, +1, −3 and +2. What is the cumulative reward?
Add all the rewards, signs included: 1 − 5 + 1 − 3 + 2 = −4. Gains total +4 and losses −8. This is the 'first try' ride in the chart above.
07

The family: supervised, unsupervised, reinforcement and transfer learning

The four kinds of learning differ mainly in the feedback they get: labels, nothing, rewards, or a model already trained on a related task, so click a column to compare them.
learning type

Pick a column above.

Transfer learning: reuse a pre-trained model, fine-tune a few layers

Click a layer to freeze it or fine-tune it.

new task

Spanish → Italian. Someone who speaks Spanish learns Italian much faster than someone starting from nothing: the grammar and many words carry over, only the differences need practice. Transfer learning reuses a model the same way.

Quick check
A shop has customer purchase records but no column saying what kind of customer each one is. It wants to find groups of similar customers. Which type of learning fits?
There is no label column, just like the fruit table without 'Fruit Type'. Clustering groups customers by their features, and people name the groups afterwards.
08

The cost and the limits: the curse of dimensionality

Every feature you add is a new dimension, and the space the data must fill grows very fast, so drag the sliders and watch the 4 problems of the curse of dimensionality appear.
features (dimensions) d10
ranges per feature r2
examples in the data n500
cells = rd · examples per cell = n ÷ rd
cells needed, d = 1 to 20 (log scale)100%
cells to cover
examples per cell
work to compare all pairs
distance contrast
Increased sparsity
Higher computational cost
Overfitting risk
Distance-based issues
Quick check
10 features split into 2 ranges each need 2¹⁰ = 1,024 cells. How many cells are needed with 11 features?
One more feature with 2 ranges doubles the count: 2¹¹ = 2 × 1,024 = 2,048. The cells grow by multiplying, not by adding, which is why the curse arrives so quickly.
09

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

Facing a new problem, answer three questions in order to pick the learning type, then install Anaconda so you are ready for the tutorial.

Pick the learning type

try a scenario
1 · Does an agent act and receive rewards over time?
2 · Does each example come with a label (the right answer)?
3 · Is the label a category or a continuous value?
+ Is there a pre-trained model for a related task?

Tutorial preparation: install Anaconda

Download the installer for your system (Windows, macOS or Linux)
Run it with the default options; it brings Python, Jupyter and the common data libraries
about 1 GB on disk, a few minutes
Open Anaconda Prompt (Windows) or a terminal and check the install
conda --version · python --version
Create an environment for the course and start Jupyter
see the commands below
# check that conda is installed
conda --version

# one environment for the course
conda create -n cds6354 python=3.11 jupyter pandas scikit-learn matplotlib
conda activate cds6354

# open the notebook interface in your browser
jupyter notebook
Quick check
A bank has past loan records, each marked 'repaid' or 'defaulted', and wants to judge new applicants. Which type fits?
No agent collects rewards, every record has a label, and the label is a category with two values (like Spam (1) / Not Spam (0)). Labelled data plus a discrete label means classification.
10

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

Each point is a milestone named in this lecture, placed on the lane of the idea it changed, so click a point for the story and the before → after.
milestones 1957–2018 · click a point100%
click a point

Before → after · tap a card to flip

Quick check
Why does Samuel's 1959 checkers program count as machine learning?
The program improved its play from experience (games played), which is exactly what Mitchell later wrote down in 1997: performance P on task T improves with experience E.
11

Where machine learning is used today

The same few learning types run very different systems, so open each row to see the type, its data and its feedback.
Every email you mark as spam becomes a labelled example: Spam (1), Not Spam (0). The features are words, senders and links. The filter keeps learning as users correct it, the same loop as the mango correction in section 02.
Utilities predict next month's electricity bill (how much) and shops predict products sold (how many) from past records. The label is a continuous number, so it is regression.
Purchase histories carry no 'customer type' column. Clustering groups similar customers; marketers then look at each group and give it a name, just as people name the fruit clusters after the algorithm has grouped them.
Supervised models recognise pedestrians, signs and lanes from labelled camera images. Driving and parking policies are refined with reinforcement learning in simulators, where staying in lane earns a reward and a collision a large penalty.
Hospitals rarely have millions of labelled scans, so they start from a pre-trained image model such as ResNet and fine-tune a few layers. Chatbots, search and translation start from pre-trained language models such as BERT.
Optical sorters on real packing lines measure color, shape, size and texture of every fruit, learn the grade of each from labelled samples, and an air jet or robot arm makes the decision in milliseconds: the lecture's scenario at industrial speed.
Quick check
A music app has no labels, only what each person played. It wants to find listeners with similar taste. What does it use?
There is no label column, so supervised learning is not possible. Clustering groups similar listening histories, and people describe the groups afterwards.
12

Key takeaways

Seven sentences to remember from Lecture 1; click each one for the evidence.
Data Mining discovers patterns, Machine Learning builds models, AI makes intelligent decisions. In the fruit plant: 'apples are usually red and smooth', learning from the mango mistake, and the robot that sorts. Sections 01–02.
Data + Answers → Rules. Mitchell (1997): performance P on task T improves with experience E. Sections 03–04.
Classification predicts discrete labels: Spam (1), Not Spam (0); Cat (1), Dog (2), Bird (3), Fish (4). Regression predicts continuous values: how much, how many. Section 05.
Remove the 'Fruit Type' column and clustering still groups fruits by color, shape, size and texture; humans assign the labels later. Sections 03 and 05.
An agent in an environment gets positive and negative rewards. The bicycle example adds the learning process: exploration and exploitation. Section 06.
Spanish → Italian. ResNet (2015) for images, BERT (2018) for language. Section 07.
4 problems: increased sparsity, higher computational cost, overfitting risk, distance-based issues. 2¹⁰ = 1,024 cells for just 10 features split in two. 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 · ML BLUEPRINT · WEEK 1 APPROVED
14

Glossary

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