learn-ml-strategy-with-phoebe / Practitioner session 3 of 10
Learn ML Strategy with Phoebe · Practitioner session 3 of 10

The error-analysis spreadsheet

Session 2 left 64 Eyeball errors in a table with an empty category column. Tonight a human fills it in, one frame at a time, and the sheet that results is the single most useful artefact in applied machine learning: one row per mistake, one column per suspected cause, a percent row at the bottom. Then two columns the book leaves to you, weeks per project and points per week, and the sheet stops being a description of the problem and becomes an order of work. On Lanternfish's sheet the smallest category comes first and the project everyone wanted to build comes last.

🟡 Core Data scientists and ML engineers 45 min
0-3 · Welcome 3-20 · Categories, shares, ceilings 20-40 · Build-along: categorise 64 errors 40-45 · Q&A
Part 0

Where tonight sits in the track

The dev set from session 1 and the baseline from session 2 have produced 120 mistakes, 64 of them in the half the team is allowed to look at. Tonight those 64 are looked at, one by one, and sorted into causes. The result is five numbers that end five arguments, and with a cost column beside them, an order of work that session 10 scores on the bench: re-label first, the specialist model last.

Live = presented in the 45 minutes Self-study = the full depth, after class 🔍 Every diagram zooms

★ What you walk out with tonight. The spreadsheet exactly as chapter 15 describes it, filled in over 64 real errors. The ceiling arithmetic from chapter 14: a category's share of the errors, times the share the project removes, times the current error rate. And the two columns that rank the projects, which on Lanternfish's sheet put a one-week re-labelling job at 1.62 points per week above an eight-week specialist model at 0.21.

LiveWhy looking at 64 mistakes beats arguing about them3 min▶

Every team has theories about why its model is wrong, and every theory has a project attached. What none of the theories have is a count. The spreadsheet is a counting device: a human looks at each misclassified example, ticks the causes that apply, and the percent row at the bottom turns opinions into shares. The whole exercise takes an afternoon for a hundred examples, which is less time than the average meeting spent arguing about which project to fund.

The counting has a second effect that is easy to miss. It surfaces categories nobody proposed. Lanternfish's team had five theories going in; wrong labels was not one of them. It turned out to be 14 percent of the errors and the best points per week on the sheet, because nobody has a theory about their own labels being wrong until they look.

Real world

Lanternfish's most senior engineer had already scoped the deer-versus-elk model before the sheet existed: eight weeks, a new dataset, a second network. On the sheet that category was 12 of 64 errors. Real, and worth 1.7 points at the ceiling, and eight weeks for 0.21 points a week. The sheet did not say the project was bad. It said four other things should happen first.

Self-studyThe vocabulary for tonight3 min▶
  • Error analysis - looking at misclassified dev-set examples by hand to understand the causes. Chapter 14 calls it looking at dev set examples to evaluate ideas.
  • Category - a suspected cause of error, one per column. Night blur, deer mistaken for elk, animal half out of frame, empty frame called animal, label was wrong.
  • Share - the percent of misclassified examples that tick a column. The bottom row of the sheet.
  • Ceiling - the most a project can improve the error rate, if it removed every error it targets. Chapter 14's word, in quotation marks in the book.
  • Removes - the share of a category's errors a project is expected to fix when it works. A denoiser will not rescue every night frame.
  • Points per week - ceiling in points of dev error, divided by weeks of work. The ranking column.
  • Eyeball half - the 500 dev frames you are allowed to look at. The sheet is over their 64 errors. Session 4 explains why the other 500 stay closed.
Part 1 · covers chapters 14 and 15

Evaluating multiple ideas in parallel during error analysis

9 min live

Chapter 15 of Machine Learning Yearning carries the title "Evaluating multiple ideas in parallel during error analysis", and its instrument is a spreadsheet. Ng: "I usually create a spreadsheet and fill it out while looking through ~100 misclassified dev set images." The columns are the suspected causes, the rows are the images, and the bottom row is the percent of total for each column. That is the entire method, and it has not needed improving since.

The spreadsheet, Eyeball half, first rows of 64 Image Night blur Deer vs elk Half out Empty frame Wrong label Comments c07_000217 ✓ antlers behind branch c03_001902 ✓ branch in wind, 3am c12_000940 ✓ ✓ IR grain, tail only c21_000058 ✓ label says elk, is deer c07_002215 ✓ 1am, heavy grain c18_003310 ✓ head out of frame ... 58 more rows ... % of total 33% (21) 19% (12) 19% (12) 16% (10) 14% (9) over 64 errors One row per mistake, one column per cause, ticks where they apply. Row three ticks two columns.
🔍 Click to zoom - the sheet as chapter 15 describes it, over Lanternfish's Eyeball errors, with the percent row that ends the argument.
LiveThe sheet exactly as the book describes it3 min▶

The shape is deliberately plain, and every part of it earns its place:

  • One row per misclassified example. Not a sample of them, not the interesting ones. Every wrong frame in the half you are looking at.
  • One column per suspected cause. Start with the team's theories. Add a column the moment you see a cause that has no column; the book's own example grew a column mid-exercise.
  • Ticks. A tick where the cause applies. Nothing more precise; a cause either explains the mistake or it does not.
  • A comments column. Free text for what the tick does not capture: "3am, branch in wind". The comments are where the next column comes from.
  • A percent-of-total row at the bottom. The share of rows that tick each column. This is the row the whole exercise exists to produce.

A spreadsheet, not a labelling tool, because the person filling it in has to be the person who will decide what to build. Delegating the looking to an annotation vendor produces a sheet nobody on the team has read.

LiveAn example can tick several columns, and the sheet is over 643 min▶

Two rules that trip people up. First, an image can tick more than one column: a night frame with an animal half out of shot is both night blur and occlusion, and both projects would help with it. So the percent row does not have to add to 100, and on the Lanternfish sheet it adds to 101 because of that overlap plus rounding. Each column's share is still a correct statement about how many errors that project could touch.

Second, the sheet is over the Eyeball half only: 64 errors, not 120. The Blackbox half stays unopened, and session 4 explains what it is for. The consequence tonight is that the shares are estimates from 64 examples, and the current error rate the ceilings are computed against is the Eyeball half's 12.8 percent, since that is the half the sheet describes.

Real world

Lanternfish's third row was an infrared frame at 2am with only a tail visible. It ticked night blur and half out of frame. Both the denoising pass and the occlusion augmentation would count it in their ceiling, and that is correct: either project might fix it, and the sheet is estimating what each could do, not dividing the credit.

Self-studyThe ceiling, from chapter 143 min▶

Chapter 14 works the arithmetic on a cat detector where 5 percent of the misclassified images are dogs: "5% is a 'ceiling' (meaning maximum possible amount) for how much the proposed project could help", so a 90 percent accurate system improves at best to 90.5 percent. The reasoning is two steps: a project that targets one category can remove at most that category's share of the errors, and the errors are a fraction of the dev set, so the improvement in accuracy is the share times the error rate.

The book's ceiling assumes the project removes every error in its category. A realistic sheet adds one more factor, the share the project is expected to remove when it works, because a denoiser does not rescue every night frame and a motion filter does not catch every empty one. The three-factor version is what Part 2 uses:

ceiling in points = share of errors x share the project removes x current error rate

For wrong labels on Lanternfish: 14 percent of the 64 errors, a re-labelling pass that fixes 90 percent of them, an Eyeball error rate of 12.8 percent. 0.14 x 0.9 x 12.8 is 1.6 points. That is the most the project can do; it is not a forecast of what it will.

Part 2 · covers the ranking columns

The two columns that turn a sheet into an order

8 min live

The percent row says how big each problem is. It does not say what to do first, because the biggest problem may also have the most expensive fix. Two more columns settle it: weeks per project, and ceiling divided by weeks. Sorted by the second, the sheet is an order of work, and it is rarely the order the team walked in with.

CategoryEyeball errorsShareProjectRemovesWeeksCeilingPoints per week
Night infrared blur2133 percentInfrared denoising pass60 percent32.50.84
Deer mistaken for elk1219 percentDeer-vs-elk specialist model70 percent81.70.21
Animal half out of frame1219 percentOcclusion augmentation50 percent41.20.30
Empty frame called animal1016 percentMotion-trigger filter80 percent21.60.80
Label was wrong914 percentRe-label the dev set90 percent11.61.62
Points of dev error per week of work, sorted Re-label the dev set 1 wk · ceiling 1.6 · 14% of errors 1.62 Infrared denoising pass 3 wk · ceiling 2.5 · 33% of errors 0.84 Motion-trigger filter 2 wk · ceiling 1.6 · 16% of errors 0.80 Occlusion augmentation 4 wk · ceiling 1.2 · 19% of errors 0.30 Deer-vs-elk specialist model 8 wk · ceiling 1.7 · 19% of errors 0.21 the project the team walked in wanting Close ceilings, eight times the cost. The smallest category on the sheet ranks first because it takes a week.
🔍 Click to zoom - the five categories ranked by points per week, with weeks and ceiling under each.
LiveWeeks per project, and ceiling divided by weeks3 min▶

The weeks column is an estimate the team already makes for every project, usually in a planning meeting far from the spreadsheet. Bringing it onto the sheet is the whole trick. Once it is beside the ceiling, dividing one by the other is a formula in a cell, and the sort order that comes out is the order of work.

On the Lanternfish sheet the ranking reads: re-label the dev set at 1.62 points per week, the infrared denoising pass at 0.84, the motion-trigger filter at 0.80, occlusion augmentation at 0.30, and the deer-versus-elk specialist model at 0.21. The denoiser and the motion filter are within 0.04 of each other, which is inside the noise of a 64-example estimate; either order for those two is defensible. The top and the bottom of the list are not close, and that is where the decision lives.

The biggest category is not first. Night blur holds a third of the errors and the largest ceiling on the sheet, 2.5 points. It ranks second, because three weeks of denoising work buys 0.84 points a week and one week of re-labelling buys 1.62. Ceiling alone would fund the denoiser first; ceiling per week says do the one-week job before it.

LiveThe mislabelled row always surprises2 min▶

Wrong labels are the smallest category on the sheet at 9 of 64, and the best points per week at 1.62, because re-labelling is a one-week job that removes 90 percent of what it targets. This pattern repeats across projects and domains: label noise is never anyone's theory, so it never has a project until the sheet gives it one, and when it does the project is cheap. It also has a second payoff the sheet does not show: every other project's ceiling was computed against errors that include the mislabelled ones, and once they are gone the remaining shares are cleaner.

Real world

Nine Lanternfish frames had labels the model disagreed with, and on inspection the model was right about all nine. Two annotators, one afternoon each, and the Blackbox error moved from 11.2 to 10.2 percent in the first week. The eight-week specialist model, funded first, would have left it at 11.2 through week 6.

Self-studyThe honest limits of the sheet3 min▶
  • Every error counts the same. A mislabelled endangered species and a blurry deer are each one row. A real deployment weights them, and a severity column is the first extension worth adding. It reorders the middle of the sheet; it does not usually rescue the eight-week project.
  • The shares are estimates from 64 examples. A category at 14 percent is really "somewhere around 14": nine frames, and one more or fewer would move it a point and a half. Treat differences of a few points between columns as ties.
  • Removes is a guess until the project ships. The 60 percent for the denoiser is an engineer's estimate. Write it down so it can be checked against what the project actually did, and adjust the next sheet.
  • Weeks are estimates too, and they are usually optimistic in the same direction for every project, which is why the ranking survives it: an eight-week project that takes twelve is still last.
  • The sheet describes the Eyeball half. The 12.8 percent the ceilings are computed against is that half's rate; the Blackbox half sits at 11.2 and will be the number reported when the projects ship.

None of these limits argue against the sheet. They argue against reading 0.84 versus 0.80 as a decision, while still reading 1.62 versus 0.21 as one.

Build-along

Categorise 64 errors and rank the projects

★ 20 min · everyone builds

Bring the dev_errors table from session 2. On the Lanternfish exercise pack the categories arrive in a file, dev_error_categories, so the arithmetic lands on the canon numbers for everyone; in real life this step is you, a viewer, and an afternoon, typing one category per frame.

Pull the 64 Eyeball errors. Only the Eyeball half. If the query returns 120 rows the where clause is missing and the Blackbox half is about to be looked at, which session 4 will explain is a mistake that cannot be undone.

★ Try it now select frame_id, predicted, actual, category from dev_errors where half = 'eyeball' order by frame_id; -- 64 rows, category null in every one

Categorise them and write the categories back. One frame at a time, with the image open. Tick every cause that applies; a night frame with a tail sticking out of shot is two ticks. The exercise pack supplies the categories so the numbers match; when it is your own model, this step is the afternoon that matters.

★ Try it now -- exercise pack: categories arrive in a file. real life: you type them, one frame at a time update dev_errors e set category = c.category from dev_error_categories c where e.frame_id = c.frame_id and e.half = 'eyeball';

Compute the share per category. This is the percent row. Expect 21, 12, 12, 10 and 9 for Lanternfish: 33, 19, 19, 16 and 14 percent of 64.

★ Try it now select category, count(*) as errors, round(100.0 * count(*) / sum(count(*)) over (), 0) as share_pct from dev_errors where half = 'eyeball' group by category order by errors desc; -- night_blur 21 33 · deer_vs_elk 12 19 · half_out_of_frame 12 19 · empty_frame 10 16 · wrong_label 9 14

Join the projects table and compute ceiling and points per week. The projects table has one row per candidate: project, category, weeks, and the share of that category's errors it is expected to remove. The ceiling is share times removes times the Eyeball error rate of 12.8; points per week divides by weeks.

★ Try it now -- projects (project, category, weeks, removes): -- re_label 1 0.9 · motion_filter 2 0.8 · ir_denoise 3 0.6 · occlusion_aug 4 0.5 · deer_elk_model 8 0.7 with sheet as ( select category, count(*) as errors, count(*) * 1.0 / sum(count(*)) over () as share from dev_errors where half = 'eyeball' group by category ), base as (select 12.8 as eyeball_err_pct) -- 64 of 500 tonight select p.project, s.category, s.errors, round(100 * s.share) as share_pct, p.weeks, round(s.share * p.removes * b.eyeball_err_pct, 1) as ceiling_pts, round(s.share * p.removes * b.eyeball_err_pct / p.weeks, 2) as pts_per_week from sheet s join projects p using (category) cross join base b order by pts_per_week desc; -- re_label 1.6 1.62 · ir_denoise 2.5 0.84 · motion_filter 1.6 0.80 · occlusion_aug 1.2 0.30 · deer_elk_model 1.7 0.21

Check the arithmetic by hand for one row, so the formula is something you understand rather than something the query did. Wrong labels: 9 of 64 is 0.14; times 0.9 removed is 0.127; times 12.8 is 1.6 points; over one week is 1.62 per week. Then the specialist model: 12 of 64 is 0.1875; times 0.7 is 0.13; times 12.8 is 1.7 points; over eight weeks is 0.21.

★ Try it now import pandas as pd sheet = pd.read_sql("select * from ranked_sheet", con) # the query above, saved as a view sheet["check"] = (sheet["errors"] / 64 * sheet["removes"] * 12.8 / sheet["weeks"]).round(2) print(sheet[["project", "pts_per_week", "check"]]) # the two columns agree, row for row

Compare with the order the team wanted. Write the team's preferred order next to the sorted sheet. On Lanternfish the team's list began with the specialist model; the sheet puts it fifth. If your two lists agree, good. If they do not, the sheet has just paid for the afternoon.

Save the sheet with the date on it. After the first two projects ship, the shares will change and the sheet will be redone over the errors that remain. The old one is the record of why the order was what it was, and the "removes" estimates on it are the ones to check against what actually happened.

Homework

Before session 4

45 min
  1. Fill in the spreadsheet for your own model's Eyeball errors, up to about a hundred rows. Add a column every time you meet a cause without one. Note how many columns you end with compared with the theories you started with.
  2. Ask each project's owner for a weeks estimate and a removes estimate, and write both on the sheet with their name. Compute ceiling and points per week and sort.
  3. Put the team's current order of work beside the sorted sheet. For every project the team has above where the sheet puts it, write one sentence on what the field gets for the wait.
  4. Find your own mislabelled row. If the sheet has no wrong-label column, add one and go back through the rows; it is the category nobody has a theory about.
Check yourself

Three questions

Wrong labels are 14 percent of the 64 Eyeball errors. A re-labelling pass is expected to fix 90 percent of them. The Eyeball error rate is 12.8 percent. What is the project's ceiling?

The ceiling is the share of errors, times the share the project removes, times the current error rate. 0.14 x 0.9 x 12.8 is 1.6 points of dev error, and over one week that is 1.62 points per week.

Night blur is 33 percent of the errors with a 2.5-point ceiling; wrong labels are 14 percent with a 1.6-point ceiling. Why does the sheet rank re-labelling first?

Ceiling says how big the prize is; weeks says what it costs. Ranked on ceiling the denoiser is first. Ranked on ceiling per week the one-week job goes ahead of it.

A night infrared frame shows only an animal's tail at the edge of the shot. How is it entered on the spreadsheet?

An example can tick several columns. Each column's share is a statement about how many errors that project could touch, so the percent row is allowed to add to more than 100.

Sources covered

What tonight maps to

✓ Machine Learning Yearning, chapter 14 Error analysis: look at dev set examples to evaluate ideas. The ceiling, with the 5 percent worked example quoted from the text.
✓ Machine Learning Yearning, chapter 15 Evaluating multiple ideas in parallel during error analysis. The spreadsheet as described, done on 64 real errors, extended with weeks and points per week.
◐ Machine Learning Yearning, chapters 17 to 18 Why only the Eyeball half is looked at. Session 4.
◐ Severity weighting of error categories Named as the first extension to the sheet. Every error counts the same tonight and on the session 10 bench.
· Metric definitions, confusion matrices, thresholds Not covered by design. The model-evaluation course owns how to score; the sheet takes "wrong" as given and asks why.

Session 3 cheat sheet

The sheetOne row per mistake, one column per cause, ticks, comments, a percent row at the bottom.
Look at about a hundredNg fills the sheet over ~100 misclassified dev images. Lanternfish has 64 in the Eyeball half.
Several ticks per row is fineThe percent row may exceed 100. Each share is what one project could touch.
CeilingShare of errors x share removed x current error rate. 0.14 x 0.9 x 12.8 = 1.6 points.
Two more columnsWeeks, and ceiling divided by weeks. Sort on the second; that is the order of work.
1.62 against 0.21Re-label in one week versus the specialist model in eight. Close ceilings, eight times the cost.
The mislabelled row surprisesSmallest category, best points per week, and nobody's theory until the sheet.
Read the shares as estimates64 examples: 0.84 versus 0.80 is a tie, 1.62 versus 0.21 is a decision.