Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Preview

DA 3.3: Data mining and simulation

This is the first page of the lesson. Read it and have a go at the activities. The rest is in the full lesson.

55 minutes

Bread and milk, together

A made-up corner shop looks at six shopping baskets. Bread and milk keep turning up together. Nobody told the shop to look for that pair. It simply showed itself.

Finding patterns nobody asked about is one kind of predictive work. Today we meet it, and a second kind: trying the future out on a computer.

Key words

WordWhat it meansExample
Data miningSearching a large amount of data for patterns nobody asked for.Items often bought together
Market basket analysisData mining that finds which items are bought in the same basket.Bread and milk
SimulationA computer model that runs a made-up situation many times to see the range of results.Two hundred pretend days of demand
Random numberA number picked with no pattern you can predict.A dice roll
SeedThe starting number a random number maker uses. The same seed gives the same run.7
ForecastAn estimate of a future value, based on the past.Next week's sales
Predictive analyticsUsing data to say what is likely to happen.Forecasts, simulations and mining

The cells students fill in are left blank in this preview.

By the end of this lesson

Note

I can explain data mining and market basket analysis, run a simulation, and say how a forecast differs from both.

Starter: last lesson

Have a go

Starter: last lesson

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Data mining: find what nobody asked for

Data mining searches a large amount of data for patterns. You do not start with a question. The pattern is the answer.

Market basket analysis is the best known kind. It counts how often two items are bought together. A shop can then put them near each other, or offer a deal on the pair.

Worked example: six baskets, three pairs

PairBaskets with bothBaskets with the first itemReading
Bread and milk45 have breadOf 5 bread baskets, 4 also have milk
Bread and jam35 have breadOf 5 bread baskets, 3 also have jam
Milk and tea25 have milkOf 5 milk baskets, 2 also have tea

The cells students fill in are left blank in this preview.

Try it: count the pairs

Code: duckdb
select a.item as item_a, b.item as item_b, count(*) as together
from baskets a
join baskets b on a.basket_id = b.basket_id and a.item < b.item
group by a.item, b.item
order by together desc, item_a, item_b;

-- The join pairs every two items in the same basket. a.item < b.item stops a pair counting twice.

Simulation: try the future out

A simulation runs a made-up situation many times, with a random number each time. It shows the range of what could happen.

The bakery bakes 85 loaves. Demand each day is a random number from 60 to 100. Run 200 pretend days and count how often it runs short. A computer makes random numbers from a seed. The same seed gives the same run.

The lesson goes on

7 more parts of this lesson are in the full curriculum, with the tasks, the final check and the labs. A college account gives your students all of it.