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

Preview

AC 2.6: Finding the story in a messy dataset

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

70 minutes

Daily visits to the school library

A librarian counted visits each day for seven days. The list has an empty entry, a word instead of a number and one day with 300, when a whole year group came in.

Is footfall growing? You can only say after you have cleaned, looked for outliers and fitted a line.

Key words

WordWhat it means
Interrogateask the data questions by sorting, filtering and counting
Cleanremove or fix values that cannot be used
Outliera value far away from the rest of the data
Skewed datadata that bunches at one end with a long tail at the other
Regressionfinding the line that best describes how one value changes with another
Medianthe middle value when the data is in order
Dataseta collection of records held together for analysis

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

By the end of this lesson

Note

I can take a messy dataset through interrogating, cleaning, handling outliers and skew, and regression, and say what it shows.

Starter

Have a go

Starter

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.

The raw readings

DayRaw entryProblem
110None
212None
3(empty)Incomplete value
4xNot a number
514None
6300Outlier: a whole year group visited
716None

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

Worked example: what each step leaves

StepWhat happensValues left
RawSeven entries10, 12, empty, x, 14, 300, 16
CleanDrop the empty one and x10, 12, 14, 300, 16
OutliersThe median is 14, so 300 is far away. Drop it and note why.10, 12, 14, 16
SkewReport the median of what is left, 1310, 12, 14, 16
RegressionSlope against day 1, 2, 3, 4 is 2Visits rise by about 2 a day

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

Try it: the first three steps

Code: python
readings = ["10", "12", "", "x", "14", "300", "16"]
numbers = []
for text in readings:
    if text.isdigit():
        numbers.append(int(text))
print("cleaned", numbers)

ordered = sorted(numbers)
middle = ordered[len(ordered) // 2]
print("median", middle)
kept = []
for n in numbers:
    if abs(n - middle) <= 100:
        kept.append(n)
print("kept", kept)

Say what you did

The finished story has numbers and reasons: "Out of 7 entries, 4 were usable. One was dropped as an empty value, one as a word, and one as an outlier, because a year group visited. The median is 13. Visits rise by about 2 a day."

Say what you removed and why, so someone else can check.

The lesson goes on

5 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.