Grid A Precision and Recall
Compute Grid A's precision 3/4 = 0.75, recall 3/6 = 0.50, and arithmetic mean 0.625 on [3, 1, 3, 23].
The problem
Grid A ([TP, FP, FN, TN] = [3, 1, 3, 23]) flags only 4 rows out of 30, keeping false alarms down to 1 while missing 3 of the 6 real positives. How high are its precision and recall, and what happens if we summarize those two rates with their plain arithmetic average (P + R) / 2?
We compute [precision, recall, arith_mean] for Grid A and vary fp_shift from -1 to +3—where fp_shift rows come out of (or return to) the 23 true negatives—to see how extra or fewer false positives move precision and the naive average while recall stays anchored.
Work through the numbers
From [TP, FP, FN, TN] = [3, 1, 3, 23] at the baseline fp_shift = 0 (FP_adj = 1 + 0 = 1):
1. Precision divides TP by flagged rows TP + FP_adj: 3 / (3 + 1) = 3 / 4 = 0.75. Three quarters of Grid A's alerts are genuine positives. 2. Recall divides TP by actual positives TP + FN: 3 / (3 + 3) = 3 / 6 = 0.50. Half of the 6 positives slip past unflagged. 3. Arithmetic mean averages the two fractions equally: (0.75 + 0.50) / 2 = 1.25 / 2 = 0.625 (5 / 8).
Shifting fp_shift to -1 eliminates the single false alarm (FP_adj = 0), lifting precision to 3 / 3 = 1.00 and arith_mean to (1.00 + 0.50) / 2 = 0.75. Raising fp_shift to +2 (FP_adj = 3) drops precision to 3 / 6 = 0.50, matching recall so arith_mean = 0.50.
The live model
Three horizontal bars on [0, 1] plot Grid A's amber precision, green recall, and blue arith_mean, above a summary card showing active FP_adj. Drag fp_shift from -1 to 3: green recall stays pinned at 0.50 because TP and FN do not change, while blue arith_mean tracks halfway between amber precision and 0.50.

let fp_shift = scene.parameter("fp_shift", 0.0, -1.0, 3.0, 1.0);
let tp = input.slice(0, 0, 1);
let fp = input.slice(0, 1, 2);
let miss_pos = input.slice(0, 2, 3);
let fp_adj = fp + fp_shift;
let precision = tp.div(tp + fp_adj);
let recall = tp.div(tp + miss_pos);
let arith_mean = (precision + recall).div(2.0);
let parts = torch.list().add(precision).add(recall).add(arith_mean);
let answer = torch.cat(parts, 0);
out.set("grid_pr_mean", answer);
{
"grid_pr_mean": [
0.75,
0.5,
0.625
]
}Your turn
Complete the [3] vector answer = [precision, recall, arith_mean] using fp_adj = fp + fp_shift. The starter adds precision + recall (1.25) without dividing by 2.0. Check evaluates unseen confusion vectors and non-zero fp_shift values.

let fp_shift = scene.parameter("fp_shift", 0.0, -1.0, 3.0, 1.0);
let tp = input.slice(0, 0, 1);
let fp = input.slice(0, 1, 2);
let miss_pos = input.slice(0, 2, 3);
let fp_adj = fp + fp_shift;
let precision = tp.div(tp + fp_adj);
let recall = tp.div(tp + miss_pos);
let arith_mean = precision + recall;
let parts = torch.list().add(precision).add(recall).add(arith_mean);
let answer = torch.cat(parts, 0);
out.set("grid_pr_mean", answer);
{
"grid_pr_mean": [
0.75,
0.5,
1.25
]
}Compute the [3] vector answer = [precision, recall, arith_mean] using fp_adj = fp + fp_shift.
Read the result carefully
An arithmetic average of 0.625 looks reasonable on Grid A because 0.75 and 0.50 sit moderately close together (0.25 apart). Yet (P + R) / 2 has a fatal blind spot: every +0.01 gain in recall trades one-for-one against a -0.01 collapse in precision, even when that precision collapse comes from flooding reviewers with false alarms. We need Grid B's numbers to see that failure mode in full, and the harmonic mean F1 on the next page to fix it.
Recap
- On Grid A (
[3, 1, 3, 23]),precision = 3 / 4 = 0.75andrecall = 3 / 6 = 0.50. - Their plain arithmetic mean is
(0.75 + 0.50) / 2 = 0.625(5 / 8). - Shifting
FPviafp_shiftmoves precision (1.00at-1down to3/7at+3) while leaving recall fixed at0.50.