In Lesson 11, we put an agent to work on its own, with written limits ("a prompt is a request, deny is a gate") and an escalation rule: uncertainty goes into the report, never into action. One question remained. How do we know whether it can be trusted? When can an assistant move from level 2 (a person approves every case) to level 3 (a person reviews only exceptions and a sample)?The Diagnostic Manual's answer is brief: only after measuring. Measure how closely the AI agrees with a person on at least 50 real cases. In this lesson, you will learn how to measure that properly: the confusion matrix, false positives and negatives, why a single number can mislead, and how to read a rigorous evaluation. The main case is the Conta Ovos egg counter, evaluated against human counts. The second is a test with a known answer that validated a program in my video pipeline. All of this feeds into the comparison spreadsheet for Project 2.1. Computer vision, labeling, and versions1.1 A model that learns from boxesRecall Lesson 1: the Conta Ovos counter is a computer vision model. A vector-control worker photographs the paddle from an ovitrap, and the model (a detector called YOLO) draws a box around each egg it finds. Nobody wrote a rule defining an egg. The model learned from examples: the version in use was trained on 214 images in which a person marked 1,839 boxes.Marking those examples is called labeling, and it provides the ground truth for everything. If a box is marked incorrectly, the model learns the mistake, and the evaluation uses a flawed reference.1.2 Who does the labeling: the "never label egg boxes" ruleLabeling is tiring, and the temptation is obvious: ask AI to do it. I tried. When Claude marked boxes around eggs, 32% of the boxes were false positives (they marked something that was not an egg), and 38% of the eggs were missed. On 20/08/2026, the rule was written down: never label egg boxes. AI measures; a human decides what counts as an egg. A few days later, on 25/08, Claude described 9 empty paddles as full, while the detector had correctly classified all nine. The rule held up.The management lesson goes beyond eggs: the ground truth must come from someone who knows the answer. If AI grades its own test, the score is meaningless.1.3 Versions: a person decides what goes liveThe counter improves in cycles. The platform stores anonymous photo samples, subject to a quota (no more than 40 per day and 200 per week). Human reviewers count the eggs in those photos. Some of the photos are used to train the next version. And a human decides whether each new version is approved for use. Version 11, the current version, was approved on 07/10/2026.Notice the setup: the machine trains, but a person decides whether to deploy it, based on a measurement. The same principle applies to autonomy levels: no one moves up without measuring first.2. The confusion matrix2.1 Four boxesStart with the simplest question the counter answers: does this paddle have eggs or not? Comparing the AI's answer with the person's, there are four possible outcomes:True positive — the paddle has eggs, and the AI says it does.False positive — the paddle is empty, and the AI reports a count. Conta Ovos has a name for this: phantom egg.True negative — the paddle is empty, and the AI says it is empty (or returns no answer).False negative — the paddle has eggs, and the AI says it does not (or returns no answer).The table containing these four boxes is called a confusion matrix. "Positive" does not mean good here: it means "the AI said the thing we are looking for is present." In fraud detection, positive means "this is fraud"; in email triage, it means "this is urgent."One important detail: the counter sometimes returns no answer when it lacks confidence ("silence instead of a guess"). In the evaluation, a photo with no count is scored as correct if the paddle was empty and incorrect if it had eggs. That rule was chosen beforehand, not after seeing the results. That, too, is part of measuring properly.2.2 The version 10 matrixVersion 10 was evaluated using photos submitted after it went live, with eggs counted by a person. We call this a prospective evaluation: the model had never seen those photos. There were 126 photos: 22 of empty paddles and 104 of paddles with eggs. The results reported in the paper (still under submission) are: it correctly identified presence or absence in 108 of the 126; it reported counts for 7 of the 22 empty paddles. Working through the numbers gives this matrix:Paddles with eggs (104): 93 true positives and 11 false negatives.Empty paddles (22): 15 true negatives and 7 false positives (phantoms).Check the totals: 93 + 15 = 108 correct results; 11 + 7 = 18 errors; 108 + 18 = 126 photos.2.3 The measures derived from the matrixAccuracy = correct results ÷ total = 108 ÷ 126 = 85.7%.Precision = of the cases where the AI said "there are eggs," how many actually had eggs? 93 ÷ (93 + 7) = 93 ÷ 100 = 93%.Sensitivity (recall) = of the cases that had eggs, how many did the AI detect? 93 ÷ 104 = 89.4%.Specificity = of the empty cases, how many did the AI correctly identify as empty? 15 ÷ 22 = 68.2%. The flip side: 7 of 22 empty paddles (31.8%) were assigned phantom eggs.An accuracy of 85.7% sounds excellent. But look at specificity: the AI invented eggs on almost a third of the empty paddles. In a surveillance program, that matters: unless the field worker corrects it, an empty paddle with a reported count is recorded as positive in the municipality's index. Each measure answers a different question, and managers need to know which error carries the greater cost.In the version 10 matrix, a paddle with eggs for which the counter returned no count is classified as:Answer: a false negative. The paddle had eggs, and the AI did not say it did. Under the rule set before the evaluation, no answer for a paddle with eggs is an error; no answer for an empty paddle is correct.3. Why a single metric can mislead3.1 The −11% that looked excellentIn August 2026, a model comparison found an error of −11% in the total egg count. In other words, across all paddles, the model counted 11% fewer eggs than the person. That looked excellent. But paddle by paddle, the model got the classification wrong (saying there were eggs when there were none, or vice versa) on 7 of 17 paddles. Overcounts and undercounts canceled each other out in the total.That led to a rule, written down on 26/08/2026: always report three metrics together. Every model comparison in Conta Ovos shows:1. Percentage error in the total egg count — does the model overcount or undercount?2. Phantom eggs — how many empty paddles were assigned a count?3. Positive/negative classification accuracy — does the AI correctly identify whether eggs are present?Each can conceal a different flaw. The total can look good because errors cancel out. Accuracy can look good despite too many phantoms. There can be zero phantoms because the model returned no answer for anything.3.2 The three together, in numbersNow read version 10 through all three: 85.7% accuracy (108 of 126), phantoms on 7 of 22 empty paddles, and a total of 771 eggs versus the human count of 1,051. The total-count calculation: (771 − 1,051) ÷ 1,051 = −280 ÷ 1,051 = −26.6%, rounded to −27%. The model is good at detecting whether eggs are present, but counts far fewer eggs than there actually are.Across all versions since measurement began, the classification was correct in 186 of 232 photos (80.2%), and the total count was 24% lower. The study's own conclusion, which you saw in Lesson 1, comes from considering all three measures together: the counter is better at distinguishing positive from negative paddles than at counting eggs; it is useful for supporting a person who checks the boxes, not for unsupervised counting.3.3 The same lesson for managementThis applies to any performance indicator. A call center that measures only average handling time gets agents who end calls quickly. A triage assistant assessed only on overall accuracy may be getting the urgent cases wrong. This is the same idea behind the Balanced Scorecard, which the manual suggests as a framework for this lesson: a single indicator is easy to game, even unintentionally. That is why we look at a small set of indicators that keep one another in check.A model's total egg count was off by only −11%, but it misclassified 7 of 17 paddles. What does this show?Answer: That overcounts and undercounts can cancel out in the total, making the total alone misleading. This case led to the rule that three metrics must always be reported together: total count, phantoms, and positive/negative classification accuracy.4. When the answer is a number: agreement4.1 CCC: do the points fall on the diagonal?The confusion matrix works for yes-or-no answers. But the counter also provides an egg count. To compare numbers, imagine a graph: the human count on the horizontal axis and the AI count on the vertical axis. If the two always agreed, every point would fall on a perfect diagonal.Lin's concordance correlation coefficient (CCC) measures how close the points are to that diagonal. It equals 1 for perfect agreement and falls as the points spread out or move away from the diagonal. The distinction from ordinary correlation matters: if the AI always counted twice as many eggs as the person, correlation would be perfect, but agreement would not, because the points would lie on a line with the wrong slope. Version 10 had a CCC of 0.861: reasonable agreement, but far from perfect.4.2 Bland-Altman: how far off the AI is, and in which directionThe second approach examines the difference for each photo (AI minus human). A Bland-Altman analysis summarizes these differences with two figures: the bias, or mean difference, and the limits of agreement, the range containing the vast majority of differences (about 95% of them).For version 10: a bias of −2.2 eggs per photo (the AI counts slightly fewer on average) and limits of −12.3 to +7.9. In plain English: for a typical photo, the AI may undercount by about 12 eggs or overcount by about 8. That works for determining whether a paddle has eggs. It does not work for saying a paddle has exactly 37 eggs. It reaches the same conclusion as the three metrics, by another route.4.3 Beware of small samplesVersion 11, the current version, had 74% accuracy and a CCC of 0.511. Worse than version 10? We cannot say. Those figures come from just 50 photos, all from 2 days. With 50 cases, an accuracy of 74% (37 of 50) has a margin of error of roughly 12 percentage points in either direction; the approximate calculation is 1.96 × the square root of (0.74 × 0.26 ÷ 50), which is about 0.12. And photos from just 2 days may come from only a few municipalities and work sessions.Another measure compares versions using the same photos, none of which appeared in any version's training data. From the original model to the current one, the number of photos correctly identified as having eggs rose from 158 to 178, and the mean error per photo fell from 5.05 to 3.09 eggs. But phantoms did not decline. Comparing versions on the same photos is fairer than comparing each over its own period.4.4 The limitations acknowledged by the studyA rigorous evaluation states what it does not measure. The paper on the counter (still under submission, not yet published) identifies three limitations: a single reader counted each set of photos, and that reader is an author of the paper; time savings were not measured; and there is no record of when the field worker changes the suggested count.Each offers a lesson for your project. A single reader cannot reveal how much two people disagree (sometimes even humans disagree). The person who built the tool may unintentionally count in its favor. And without measuring time, the business case in Lesson 9 is missing its key figure. It is no coincidence that Project 2 asks you to measure time saved.Version 11 achieved 74% accuracy on 50 photos taken over 2 days; version 10 achieved 85,7% on 126 photos. What is the most defensible interpretation?Answer: With 50 photos from just 2 days, the difference could be down to chance. The margin of error for 50 cases exceeds ten percentage points, and the photos may come from only a few sessions. Testing both versions on the same photos is the fair way to compare them.5. Testing with a known answer5.1 How to validate a measuring toolSometimes a human comparison is not an option because what you are measuring is hard to see with the naked eye. That was the case with my synchronization tool. On 22/11/2026, one of my videos came out with the camera image lagging 0,43 seconds behind the voice. That same day, I created sincronia.py, which matches mouth movements against voice volume to calculate the delay. In a properly synchronized recording, it measures −70 to 0 milliseconds (the mouth moves slightly before the sound).How do you know whether the tool measures correctly? With a known-answer test: we take the recording, deliberately delay the audio by 300 milliseconds, and measure again. If the tool works, the measurement must shift by exactly 300 ms. It did. Instead of comparing it with a person, we compared it with an error we had deliberately introduced and whose size we knew.5.2 The fix needs checking tooThe same case exposed a second error within the first. The delay correction was calculated in frames for a video running at 60 frames per second, but the recording ran at 30. As a result, the shift became 0,87 seconds instead of 0,43. The script now reads the file's frame rate before calculating. The management lesson: measuring the problem is not enough; measure the result of the fix too.Known-answer tests are useful in many processes. To test an assistant that flags invoices with incorrect amounts, you could take 20 correct invoices, deliberately change the amounts on 5, and check whether it identifies exactly those 5.6. Measuring a game: the Futebol de Carta simulator6.1 The game and the questionFutebol de Carta is a card game I am building: a real-time, 1-on-1 match with two 10-minute halves, where each card played represents a player performing an action. The rules are set out in a design document, the GDD, explicitly labeled a draft: its numbers are starting points for testing, not established facts. The question for a game is the same as for an assistant: is it working as intended? Does any team win too often? Are there too few goals? Is there a single play that decides everything?Playing a thousand matches manually is not feasible. That is why the project separates out the rules engine (code containing only the rules, with no interface) and keeps all adjustable values in one place. This makes the simulator possible: a bot plays against another bot for as many matches as you request, recording what happens.6.2 9.000 matches, before and afterThe evaluation recorded in the GDD on 27/10/2026 covered 9.000 matches, with every team playing every other team. The results: around 3,3 goals per match, around 9,7 shots with a conversion rate of around 34%, win rates between 34% and 40% for each of the 10 teams, and around 25% draws. The environment card changes the game: from 2,0 goals per match in Rain to 3,9 on a Pristine Pitch.The most useful part is the record of each change, including the date, the request, and its measured effect. On 19/10/2026, I asked for matches with around 3 goals; the center-backs lost 1 defense point, and the average rose from 2,2 to 2,9 goals. Changing a rule without measuring before and after is guesswork.6.3 A rule the player never seesThere is also an internal design rule: a 1-card play must have no more than a 5% chance of scoring; a 2-card play, 10%; a 3-card play, 40%. The benchmark is the 90th percentile: not the average, but the value above 9 out of every 10 cases, so that a strong play cannot hide among many weak ones. A program, limites.py, checks the rule and exits with an error if any limit is exceeded. To stay within those limits, the recorded lesson was that "adjusting skill alone was not enough": a new defensive rule was introduced, and +2 cards became +1 cards.6.4 Parity: checking that two versions agreeThe game has two matching engines: one in JavaScript, which runs in the browser, and one in Python, because the server runs Python and determines the outcome of the match. Two copies of the rules pose a risk: someone might change one and forget the other. The parity test runs the same bot-versus-bot matches in both engines, using the same seed (the number that makes random draws come out the same in both), and compares the entire game state at every decision, right down to the commentary text: 12 matches, 260 decisions per half. The project's CLAUDE.md puts it this way: "parity catches the side you forgot".This takes the agreement discussed in section 4 to its logical extreme: there is no tolerance here; the two versions must agree at every step. In management, this applies to any system changeover: before retiring the old spreadsheet, run both with the same data and compare them line by line.What does the Futebol de Carta parity test measure?Answer: Whether both engines, using the same seed, reach the same game state at every decision. It checks that two implementations agree; goals per match and the 5% limit are checked by the simulator and limites.py.7. The Project 2 comparison spreadsheet7.1 How to set it upProject 2 calls for 50 cases compared against human decisions. Use one row per case, with these columns:case (a number), input (the email, the document, or a link to it), human decision, AI decision, agreement?, error type (false positive or false negative), human time and time with AI, and notes.Take three precautions. Record the human decision before looking at the AI's decision, or it will influence the person. Select cases from a defined period rather than cherry-picking the easiest ones. And decide in advance how to handle cases the AI refers to a person (its "silence"), as in Conta Ovos.7.2 A worked exampleA fictional example: a triage assistant labels customer emails "urgent" or "not urgent". Out of 50 emails, the person labeled 12 urgent. The assistant labeled 14 urgent, of which 10 actually were urgent. The matrix:10 true positives, 4 false positives, 2 false negatives, 34 true negatives. Check: 10 + 4 + 2 + 34 = 50.Accuracy = (10 + 34) ÷ 50 = 88%. Precision = 10 ÷ 14 = 71,4%. Sensitivity = 10 ÷ 12 = 83,3%.Now for the trap. An "assistant" that labeled everything "not urgent", without reading anything, would get 38 out of 50 right: 76%. That sounds reasonable, but it is useless because it misses every urgent email. This is why the Project 2 report should never give accuracy alone: include the full matrix, the errors that matter (here, the 2 missed urgent emails), and the time taken.8. Terms you need to knowKnowing the subject matters more than knowing AI. People who know the right terms can give the agent clear instructions and know what to check. "See if the AI is any good" says nothing; "build the confusion matrix, calculate sensitivity, and list the false negatives" is a request the agent can carry out and you can verify with a calculator. In the game, it is the difference between "is the game difficult?" and "run 9.000 matches in the simulator and show me the 90th percentile of the scoring probability per play".TermWhat it meansWhere it appears in the projectLabelingManually marking the correct answers in the examples (the boxes around the eggs); this is the ground truthConta Ovos: YOLO trainingConfusion matrixA table of true and false positives and negativesConta Ovos: version 10 evaluationFalse positive / phantom eggThe AI reports something that is not there; in the counter, a count on an empty paddleConta Ovos: 7 of 22 empty paddlesPrecision / sensitivityOf the cases the AI flagged, how many were correct; of the cases actually present, how many it foundConta Ovos and the Project 2 spreadsheetProspective evaluationTesting on previously unseen cases that arrived after the model was readyConta Ovos: the 126 photos for version 10CCC and Bland-AltmanAgreement between two numbers: proximity to the diagonal, and the size and direction of errorsConta Ovos: AI counts versus human countsKnown-answer testIntroducing an error of a known size and checking whether the measuring tool detects itVideos: sincronia.py with a 300 ms delayRules engineCode containing only the game rules, with no interface, that can be tested independentlyFutebol de Carta: motor.js and motor.pySimulatorA bot plays many matches against another bot to measure game balanceFutebol de Carta: 9.000 matches in the GDD90th percentile (p90)The value above 9 out of every 10 cases; the benchmark for the internal ruleFutebol de Carta: tools/limites.pySeedA number that makes random draws come out the same every time, in both enginesFutebol de Carta: parity testParity testChecks that two versions of the same program produce the same resultFutebol de Carta: 12 matches, 260 decisions per half9. Common mistakes"It got 88% right, so it passes." That depends on the errors. An assistant that never flags anything can have high accuracy. Look at the matrix and the most costly error."I asked the AI to check the AI's result." Ground truth comes from someone who knows the answer. In Conta Ovos, when the AI did the labeling, 32% of the boxes were false."I tested it on 10 cases and it worked." With so few cases, the margin of error is enormous. It already exceeds ten percentage points with 50 cases; with 10, it is much larger."The total matched, so it must be right." Overcounts and undercounts cancel each other out. The −11% concealed errors in the wrong direction on 7 of 17 paddles.10. Bringing it all togetherMeasurement is what lets you level up. The guide calls for 50 real cases compared with a person’s judgment before giving the AI more autonomy.The confusion matrix separates errors: false positives (the ghosts) and false negatives (what slipped through) have different costs, while accuracy, precision, sensitivity and specificity answer different questions.Three metrics, always together: in Conta Ovos, total count, ghosts and correct positive or negative classifications. Version 10 correctly detects 85.7% of presences, but produces ghosts in 7 of 22 empty strips and undercounts by 27%.Serious evaluation states its limits: a small sample (the 50 cases from version 11), a single reader, the author serving as evaluator, and unmeasured time. And when there is no person to compare against, a known-answer test (delay the signal by 300 ms and see whether the measurement shift by 300 ms) validates the measuring tool.Measurement matters for a game too: in Futebol de Carta, the simulator measures balance before and after each rule change, while the parity test checks that the two twin engines agree on every decision.Projeto 2 is this lesson put into practice: a 50-row spreadsheet, the human decision recorded first, a complete matrix and measured time.In the next lesson, we look at what can go wrong beyond measurement error: risks, LGPD and AI governance.Activity in Claude Code (20 minutes)1. In your Projeto 2 folder, set aside 20 real cases from the process you chose. Before running the assistant, record your decision for each case in a spreadsheet (the "human decision" column). Do not look at what the AI would say.2. Ask: "Run the assistant on these 20 cases and fill in the 'AI decision' column in the spreadsheet without changing the 'human decision' column."3. Ask: "Write a script that reads the spreadsheet, calculates the confusion matrix, accuracy, precision and sensitivity, and lists every false-positive and false-negative case. Save the result as avaliacao.md."4. Check by hand: count the false negatives in the spreadsheet yourself and compare the result with the script’s count. Recalculate one of the figures (precision, for example) with a calculator.5. Ask: "Also show the accuracy of an assistant that always gave the same answer (the most common answer). Is our assistant better than that?"6. Read the errors one by one and choose the one that would cost the most in real life. Ask it to record a dated rule in CLAUDE.md along the lines of: "Always evaluate with a complete matrix and an error list; never accuracy alone. Record the human decision before the AI."Exercise for class discussionThe Conta Ovos counter does a good job of detecting whether eggs are present, but it produces ghost eggs on about one-third of empty strips and, overall, counts far fewer eggs than the person does. Imagine you are the public health surveillance manager for a municipality. (a) Which error costs you more: the ghost (an empty strip classified as positive) or the false negative (a strip with eggs classified as empty)? Why? (b) Given these figures, at what level of autonomy would you use the counter? (c) What measurement would you request before promoting the next version, and on how many photos?Exercises1) An antifraud assistant flagged 20 transactions as suspicious. Of those, 15 were actually fraud. During the same period, there were 25 fraudulent transactions in total. The assistant’s precision and sensitivity are, respectively:A) 60% and 75%.B) 75% and 60%.C) 75% and 75%.D) 80% and 60%.E) 60% and 60%.2) In the Conta Ovos counter, a "ghost egg" is:A) an egg counted by the person but missed by the AI (false negative).B) an egg marked twice by the person.C) a photo that is not of a strip.D) a number assigned by the AI to an empty strip (false positive).E) an egg that has already hatched.3) The rule "three metrics, always together" was created in Conta Ovos because:A) an overall error of −11% hid the fact that the model got the classification wrong on 7 of 17 strips, since opposite errors canceled each other out.B) the article required three tables.C) three metrics make the model faster.D) the person counting the eggs made many mistakes.E) the model had 100% accuracy and its flaws needed to be found.4) To validate the voice-and-image synchronization measurement, the audio was deliberately delayed by 300 ms. This procedure is an example of:A) labeling performed by the AI.B) quota sampling.C) a known-answer test: an error of known size is introduced to see whether the measurement detects it.D) a confusion matrix.E) prospective evaluation with people.5) (True or false) "Lin’s concordance correlation coefficient (CCC) is 1 when the AI’s and the person’s measurements match perfectly; if the AI always counted twice as much as the person, the correlation would be high, but the agreement would not."( ) True ( ) False6) (True or false) "Since version 11 of the counter had 74% accuracy on 50 photos and version 10 had 85.7% on 126 photos, it has been demonstrated that version 11 is worse than version 10."( ) True ( ) FalseAnswer Key1) B — Precision = 15 ÷ 20 = 75% (of the flagged transactions, how many were fraud). Sensitivity = 15 ÷ 25 = 60% (of the fraudulent transactions, how many were caught). Option A switches the two.2) D — A ghost is the counter’s false positive: a number recorded on an empty strip. In version 10, this happened on 7 of 22 empty strips.3) A — The overall figure looked good because the overcounts and undercounts canceled each other out. Hence the three measures together: total count, ghosts and correct positive or negative classifications.4) C — The answer was known (300 ms), and the measurement shifted by exactly 300 ms. This is how to validate a measuring tool when there is no person to compare against.5) True — Correlation measures whether the points lie on any straight line; agreement measures whether they lie on the diagonal where the AI and the person give the same number.6) False — With 50 photos from 2 days, the margin of error exceeds ten points, and the sample may represent only a few sessions. The difference could be due to chance; comparing the versions on the same photos is the fair approach.
Reactions
0
0 Comments
Be the first to comment
Nothing here yet.