Two analysts, one answer
Two analysts find the busiest day in a made-up cafe's sales. Both get Saturday. One finishes in a blink. The other makes the computer work 12 times harder.
Then each writes the result for the owner. One gives six decimal places. The owner wanted one line. Good analysis needs the right method and the right amount of detail.
Key words
| Word | What it means | Example |
|---|---|---|
| Algorithm | A set of steps for doing a job. | Find the highest value |
| Efficient | Gets the answer with few steps and little waste. | One pass over the data |
| Level of detail | How much information a result shows. | A weekly total, not every sale |
| Accuracy | How close a figure is to the true value, and how many places it shows. | 3.97 or about 4 |
| Representation | The form a result is shown in. | A table, a line chart or one sentence |
| Requirement | What the finished analysis must be able to show. | Show if sales rise each week |
| Database | A store of organised data, kept in tables. | The sales tables |
| Loop | Code that repeats the same steps. | A loop over every value |
| Audience | The people who will read the result. | The cafe owner |
The cells students fill in are left blank in this preview.
By the end of this lesson
Note
I can apply a method efficiently, show the result at the right level of detail and accuracy, and review it against the requirement.
Starter: last lessons
Have a go
Starter: last lessons
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Apply a method efficiently
An algorithm is a set of steps. Two algorithms can give the same answer in a very different number of steps.
Find the highest value. You can compare every value with every other, or look at each value once and remember the highest so far. The second is efficient. With a million rows, the difference is hours.
Try it: count the steps
values = [40, 42, 45, 50, 70, 90, 30, 48, 50, 53, 58, 78]
slow_steps = 0
slow_answer = 0
for a in values:
is_highest = True
for b in values:
slow_steps = slow_steps + 1
if b > a:
is_highest = False
if is_highest:
slow_answer = a
fast_steps = 0
fast_answer = values[0]
for v in values:
fast_steps = fast_steps + 1
if v > fast_answer:
fast_answer = v
print("Compare every pair:", slow_answer, "in", slow_steps, "steps")
print("One pass:", fast_answer, "in", fast_steps, "steps")
Habits that save work
- Use the simplest method that meets the requirement.
- Let the database do the adding up. A group by is quicker than your own loop.
- Test on a small sample first.
- Do not repeat work you already did. Keep the result and reuse it.
Show it at the right level
Choose the level of detail and the accuracy to suit the audience and the requirement.
The owner needs a headline, such as "Sales rise about 8 a week". A data team may need the slope to two places and a table by day. Too much detail hides the answer. Too little cannot be checked.
Worked example: one result, three audiences
| Audience | Level of detail | Accuracy | Form |
|---|---|---|---|
| Cafe owner | One headline | Whole numbers: about 8 a week | A sentence and one line chart |
| Shop manager | Totals by week | One decimal place | A small table |
| Data team | Every day, with the method | Two decimal places | Table, chart and a note on the method |
The cells students fill in are left blank in this preview.