Threshold Five Sixths Counts
Raise the cutoff to 5/6 on the nine scored rows and tally [TP, FP, FN, TN] = [2, 0, 2, 5] as both false alarms clear.
The problem
At Threshold One Half Counts (sixths = 3), two negative rows—0.70 and 0.60—slipped into the flagged pool, giving [TP, FP, FN, TN] = [3, 2, 1, 3]. To eliminate both false alarms, we raise the cutoff above 0.70 to five sixths (sixths = 5, so cutoff = 5 / 6 ≈ 0.8333).
On the identical nine rows [0.95, 1], [0.90, 1], [0.75, 1], [0.70, 0], [0.60, 0], [0.40, 1], [0.30, 0], [0.15, 0], and [0.10, 0], we compute [tp, fp, miss_pos, tn] at sixths = 5.
Work through the numbers
Trace which rows remain above 5 / 6 ≈ 0.8333 and which fall below:
- Rows
0, 1(0.95, 0.90) exceed0.8333and carryy = 1, givingTP = 2andFP = 0(pred_pos = 2). - Three rows sit inside the swept interval
(0.50, 0.8333]: row2(0.75,y = 1) moves fromTPintoFN, while rows3, 4(0.70, 0.60, bothy = 0) move fromFPintoTN. - Combining row
2(0.75) with row5(0.40) givesFN = 2; combining rows3, 4with rows6, 7, 8(0.30, 0.15, 0.10) givesTN = 5.
The confusion vector shifts from [3, 2, 1, 3] at 3 / 6 to [2, 0, 2, 5] at 5 / 6 (2 + 0 + 2 + 5 = 9). Notice the pool conservation: actual positives remain TP + FN = 2 + 2 = 4, actual negatives remain FP + TN = 0 + 5 = 5, and flagged alerts shrink from 5 down to 2 pure true positives.
The live model
Four cell cards show [TP, FP, FN, TN] above two pool bars comparing flagged = TP + FP against actual_pos = TP + FN. Step sixths from 3 ([3, 2, 1, 3]) to 4 ([3, 1, 1, 4]) and 5 ([2, 0, 2, 5]): at 5 / 6, the amber FP card hits 0 so the flagged pool (2) becomes a strict subset of the 4 actual positives.

let sixths = scene.parameter("sixths", 5.0, 1.0, 5.0, 1.0);
let cutoff = sixths / 6.0;
let prob = input.select(1, 0);
let label = input.select(1, 1);
let pred = prob.gt(cutoff).to(DType.F64);
let neg_pred = pred.rsub(1.0);
let neg_label = label.rsub(1.0);
let tp = (pred * label).sum();
let fp = (pred * neg_label).sum();
let miss_pos = (neg_pred * label).sum();
let tn = (neg_pred * neg_label).sum();
let top = torch.list().add(tp.reshape(1)).add(fp.reshape(1));
let answer = torch.cat(top.add(miss_pos.reshape(1)).add(tn.reshape(1)), 0);
out.set("counts_five_sixths", answer);
{
"counts_five_sixths": [
2,
0,
2,
5
]
}Watch the parameter change
Your turn
Complete [tp, fp, miss_pos, tn] under prob > sixths / 6.0 so miss_pos counts actual positives left at or below cutoff. The starter sets miss_pos to neg_pred.sum(), counting all 7 unflagged rows—including 5 true negatives—as missed positives. Check tests unseen tables and sixths cutoffs.

let sixths = scene.parameter("sixths", 5.0, 1.0, 5.0, 1.0);
let cutoff = sixths / 6.0;
let prob = input.select(1, 0);
let label = input.select(1, 1);
let pred = prob.gt(cutoff).to(DType.F64);
let neg_pred = pred.rsub(1.0);
let neg_label = label.rsub(1.0);
let tp = (pred * label).sum();
let fp = (pred * neg_label).sum();
let miss_pos = neg_pred.sum();
let tn = (neg_pred * neg_label).sum();
let top = torch.list().add(tp.reshape(1)).add(fp.reshape(1));
let answer = torch.cat(top.add(miss_pos.reshape(1)).add(tn.reshape(1)), 0);
out.set("counts_five_sixths", answer);
{
"counts_five_sixths": [
2,
0,
7,
5
]
}Compute [tp, fp, miss_pos, tn] under rule prob > sixths / 6.0 so miss_pos counts only unflagged positive rows.
Read the result carefully
Eliminating the two false positives at 0.70 and 0.60 cost us row 2 (0.75, y = 1) only because we jumped in sixths from 4 / 6 ≈ 0.6667 to 5 / 6 ≈ 0.8333, sweeping across 0.70 and 0.75 in one step. At sixths = 5, zero false positives (FP = 0) means the flagged pool (2) contains no noise at all, while FN = 2 means half of the 4 positives sit unflagged.
Recap
- Raising the cutoff to
5 / 6(sixths = 5) turns[3, 2, 1, 3]into[TP, FP, FN, TN] = [2, 0, 2, 5]. - Rows
3, 4(0.70, 0.60) move fromFPtoTN, and row2(0.75) moves fromTPtoFN. - With
FP = 0, all2flagged rows are true positives, while2of the4actual positives remain missed.