Step 1 of 11 · 0 done
Machine Learning · Week 1 · Lecture 1 · Introduction to Machine Learning · Guided tutorial · Beginner

Introduction to Machine Learning: learn it by doing it

By the end you will be able to sort any learning task on a fruit-sorting belt into supervised, unsupervised, reinforcement or transfer learning, and explain why adding features can make learning harder.

Before you startHow to read a table of data (rows are examples, columns are measurements) and the everyday habit of sorting things into groups. No programming needed. The theory is on the Blueprint page; this page makes you do it.

11
steps, one idea each
≈ 50 min
estimated time
✎
you need: pen and paper
1957–2018
from the perceptron to BERT
01

Match each fruit-belt job to its field

Step 1 of 11 · ≈ 4 min

Explain

Data Science is the big umbrella for getting value out of data. Under it the lecture puts 3 fields, each with its own job: Data Mining discovers hidden patterns in data you already have, Machine Learning builds models that learn from examples and improve, and AI makes the intelligent decision and acts on it.

Our running example, used in every step: a factory belt carries apples, bananas, oranges and mangoes, and a machine must put each fruit in the right bin. Each fruit is described by 4 features: color, shape, size and texture.

DATA SCIENCE Data Mining Machine Learning AI discovers patternsbuilds modelsmakes decisions

AnalogyA kitchen team: one person studies the recipes (patterns), one practises until the dish is right (learning), one serves it to the guest (deciding and acting).

Try it

Three jobs happen on the fruit belt. Pick the field that does each one.

1The sorter wrongly identified a mango as an apple, a worker corrected it, and the next mango is named correctly.

2A robot looks at the fruit, answers “Which fruit is this?” and picks the apples and oranges into their bins.

3Last year's belt records show that “Apples are usually red and smooth” and “Bananas are yellow and cylindrical”.

02

Spot the sorter that really learns

Step 2 of 11 · ≈ 3 min

Explain

In ordinary programming a person writes the rules (“if red and round, it is an apple”) and the computer only follows them. Machine learning turns this around: you give the computer data with the right answers and it works out the rules itself. It learns from data and improves its performance without being explicitly programmed.

Arthur Samuel (IBM) popularised the term in 1959 with a checkers program that got better by playing. In 1997 Tom Mitchell made it precise: a program learns from experience E on tasks T, measured by performance P, if P improves with E. For our sorter: T = name the fruit, E = labelled fruits seen, P = share of fruits named correctly.

program: data + rules → answers
ML: data + answers → rules (a model)

AnalogyA recipe card never changes; a cook who tastes and adjusts gets better with every meal.

Try it

Four fruit sorters are on sale. Which one is machine learning?

03

Find the label in the fruit table

Step 3 of 11 · ≈ 3 min

Explain

Picture the belt records as a table: each row is one fruit, each column one measurement. A feature is an input you can measure on any fruit, even a brand-new one: our 4 are color, shape, size and texture. A label is the answer you want the model to give.

When every row comes with its label, the data is labeled. Learning to map the inputs (features) to the outputs (labels) is called supervised learning: studying with an answer key.

AnalogyA doctor: the symptoms are the features, the diagnosis is the label.

Try it

Click (or Tab to and press Enter on) the column the model must learn to predict: the label.

COLORredyelloworange SHAPEroundcylindricalround SIZEmediumlongmedium TEXTUREsmoothsmoothdimpled FRUIT TYPEAppleBananaOrange

No column chosen yet.

04

Sort tasks into classification or regression

Step 4 of 11 · ≈ 4 min

Explain

Supervised learning comes in 2 types, decided by what the label looks like.

Classification: the label is a category from a fixed list (discrete). Email spam detection uses Spam (1), Not Spam (0); an animal classifier uses Cat (1), Dog (2), Bird (3), Fish (4). Those numbers are only names: a Bird is not “3 times a Cat”.

Regression: the label is a continuous value that answers “how much?” or “how many?”, such as a monthly electricity bill (how much) or the number of products sold (how many).

CatDogBird classification: which one? 0more regression: how much / many?

AnalogyA teacher can either sort essays into grade bands (a category) or write an exact mark out of 100 (an amount).

Try it

Each task has labelled examples. Mark it classification or regression.

1Predict next month's electricity bill of a house.

2Tell which animal is in a photo: Cat (1), Dog (2), Bird (3), Fish (4).

3Name the fruit on our belt: apple, banana, orange or mango.

4Predict how many products the fruit shop will sell this week.

5Decide whether an email is Spam (1) or Not Spam (0).

05

Name what happens when the labels are gone

Step 5 of 11 · ≈ 4 min

Explain

Now imagine the belt records lost their “Fruit Type” column. Only the 4 features remain, so there is no answer key: the data is unlabeled. This is unsupervised learning.

The computer can still put fruits that look alike together, using color, shape, size and texture. This grouping is called clustering. The computer never learns the word “mango”; it only finds “these fruits are similar to each other”. Humans look at each group afterwards and assign the labels.

color →size ↑ group ?group ?group ?

AnalogyA child sorting a box of buttons by colour and size, without being told any names.

Try it

Fill in the two blanks.

Without the “Fruit Type” column, grouping similar fruits by their features is called (one word), and the names of the groups are given afterwards by .

Spelling is forgiving: capitals and small typos in endings are fine.

06

Your turn: name a new fruit from three examples Your turn

Step 6 of 11 · ≈ 7 min · pen and paper

Explain

Time to use steps 3 to 5 together. Here is a simple way to name a new fruit from labelled examples. Give each fruit two practice scores from 0 to 10: colour (0 = yellow, 10 = red) and size (0 = small, 10 = long).

To compare the new fruit with one example, take the gap on colour and the gap on size (always positive, bigger minus smaller) and add them. The example with the smallest total gap is the closest, and the new fruit copies its label.

mini-example: new (3, 6) vs banana (2, 7)
gap = (3 − 2) + (7 − 6) = 1 + 1 = 2

AnalogyMeeting a stranger and asking: which of my friends does this person look most like?

Try it · 3 parts
fruitcoloursizelabel
example A84apple
example B27banana
example C55orange
new fruit74?

(a)Work out the total gap from the new fruit to each example. Type the smallest total gap.

score points

A whole number; it must be exact (tolerance 0).

(b)Which label does the new fruit get?

(c)What kind of task did you just do?

07

Put the bicycle-riding steps in order

Step 7 of 11 · ≈ 5 min

Explain

Sometimes nobody has the answers at all. In reinforcement learning an agent acts in an environment, gets a positive reward or a negative one (a penalty), and tries to maximise the long-term cumulative reward, not just the next one.

5 components describe every moment: State (S), the situation now; Action (A), what the agent does; Reward (R), how good or bad the result was; Next State (S'), the new situation, which becomes the next S; Policy (π, “pi”), the agent's rule for which action to take in each state. Our sorter's robot arm could learn a gentle grip this way; the lecture's example is a child learning to ride a bicycle.

agent (child) environmentbike · road Action A Reward R + Next State S' Sutton & Barto's 1998 textbook made this the standard picture

AnalogyNobody can explain balance to a child, but falling hurts and gliding feels great.

Try it

The lecture's 6 steps of learning to ride a bicycle are shuffled. Use ↑ and ↓ to put them in order, from the first to the last.

  1. 1Learning Processover many rides the child mixes exploration (trying new moves) with exploitation (repeating moves that worked)
  2. 2Reward (R)staying up and moving feels good; wobbling or falling hurts
  3. 3State (S)the child sits on the bike, which is still and upright
  4. 4Policy (π)the child's growing sense of what to do in each situation: “leaning left → steer gently left and keep pedalling”
  5. 5Action (A)the child pushes the pedals and turns the handlebars a little
  6. 6Next State (S')the bike is now moving slowly, leaning left; this becomes the new S

08

Choose how to reuse a pre-trained model

Step 8 of 11 · ≈ 4 min

Explain

Someone who already speaks Spanish learns Italian much faster than someone starting from zero: the grammar and many words carry over. Transfer learning works the same way.

A pre-trained model has already learned from a huge dataset: ResNet (He et al., ImageNet winner in 2015) for images, or BERT (Devlin et al., Google, 2018) for language (NLP). Its early layers already spot general things such as edges, shapes and textures. To reuse it for a related task you fine-tune it: keep most of the model and update only a few layers with your own, smaller dataset, instead of training from scratch.

fine-tune (top layers) kept from ResNet:edges, shapes, textures new task: our fruit

AnalogySpanish → Italian: you reuse what you know and practise only what is new.

Try it

The factory now wants its camera to spot bruised mangoes, but it has only a small set of labelled mango photos. What should the team do?

09

Predict how fast the cells multiply

Step 9 of 11 · ≈ 4 min · pen and paper

Explain

Every feature you add is one more dimension. Split each feature into just 2 ranges (low and high). With 1 feature you get 2 cells; with 2 features a 2 × 2 grid of 4 cells; with 3 features a cube of 8. Each new feature splits every existing cell in two, so the number of regions doubles with every added dimension.

Our 4 fruit features already give 2 × 2 × 2 × 2 = 16 cells. Your data does not double, so more and more cells stay empty. Richard Bellman named this the curse of dimensionality in 1957.

1 feature: 22 features: 43 features: 8

AnalogyFinding a lost coin along one hallway is easy; in a whole building with many floors, almost every room is empty.

Try it

The engineers grow the fruit records to 10 features, each split into just 2 ranges. Set the slider to your prediction of how many cells are needed to cover the data.

Within ±128 of the true value counts as right. Work it out on paper first.

your prediction0cells
05001,0001,5002,000
10

Match each symptom to its problem

Step 10 of 11 · ≈ 4 min

Explain

As the cells multiply, the lecture lists 4 problems:

  1. Increased sparsity: the same data spreads over far more cells, so most cells are empty.
  2. Higher computational cost: more features mean more numbers to store and process, so training is slower and needs more memory.
  3. Overfitting risk: with so much empty room the model can memorise the few training examples and then do badly on new ones (overfitting).
  4. Distance-based issues: methods that compare distances, such as k-NN and clustering, suffer because in many dimensions all points appear equally distant.

AnalogyIn a stadium where everyone sits far apart, “the person nearest to you” is barely nearer than anyone else.

Try it

The 10-feature fruit sorter shows four symptoms. Pick the problem behind each.

1It names every training fruit perfectly but gets many new fruits wrong.

2When it looks for the most similar past fruit, every fruit seems about equally far away.

3Most of the 1,024 cells contain no fruit at all.

4Training now takes far longer and needs much more memory.

11

Put it all together: plan the factory upgrade

Step 11 of 11 · ≈ 8 min

Explain

The factory is upgrading its fruit sorter, and every job in the plan uses one idea from steps 1 to 10. Three questions sort almost everything:

  1. Is it finding patterns, learning, or deciding and acting? (step 1)
  2. Does the data have labels? If yes: a category or an amount? (steps 3–6)
  3. Does the learner get rewards, or reuse a model someone already trained? (steps 7–8)

And keep the cost of adding features in mind (steps 9–10).

AnalogyA head chef planning a new menu: each task goes to the right person.

Try it · capstone

For each of the 8 jobs in the upgrade plan, pick the idea it uses. Each idea is used exactly once.

✓

What you can do now

Each outcome is ticked when the steps that teach it are done

    Before the first lab: install Anaconda (docs.anaconda.com/anaconda/install/).

    Your score
    0 / 11

    steps solved without the worked answer

    Go to the Blueprint quiz →