Always-N Baseline
Evaluate a constant negative prediction rule against skewed labels to establish the zero-feature baseline.
The problem
Once label counts show four negative rows and one positive row, a natural question precedes any learned classifier: what happens if a rule ignores every measurement and predicts 0 on every row? That constant negative rule is the Always-N baseline.
Consider five scored observations [0.10, 0], [0.15, 0], [0.35, 1], [0.20, 0], and [0.42, 0]. The first column holds a risk score and the second holds the true class. Before evaluating any score threshold, we evaluate a constant baseline prediction across all five rows and count exact matches, misses, and the resulting match rate.
Work through the numbers
Set baseline = 0. The prediction vector is [0, 0, 0, 0, 0], compared element by element against true labels [0, 0, 1, 0, 0]. Rows 0, 1, 3, and 4 have true label 0, so equality produces [1, 1, 0, 1, 1].
Adding that equality indicator gives 1 + 1 + 0 + 1 + 1 = 4 matches. Subtracting from 5 total rows leaves 5 - 4 = 1 miss, which occurs on row 2 where the single positive case sits. Dividing 4 matches by 5 rows yields a match rate of 4 / 5 = 0.8.
Flipping the constant rule to baseline = 1 predicts [1, 1, 1, 1, 1] instead. Equality against [0, 0, 1, 0, 0] becomes [0, 0, 1, 0, 0], giving 1 match on row 2, 4 misses on the negative rows, and a match rate of 1 / 5 = 0.2.
The live model
Each column in the top diagram pairs one row's true class with the constant baseline prediction, marking matches in green and misses in red. Below the row cards, horizontal bars display [matches, misses, match_rate]. Toggle the baseline slider between 0 and 1 to see how switching from Always-N to Always-P trades four negative matches for one positive match.

let baseline = float(int(scene.parameter("baseline", 0.0, 0.0, 1.0, 1.0)));
let labels = input.select(1, 1);
let n = labels.numel();
let total = float(n);
let pred = torch.full(n, baseline).to(DType.F64);
let matched = labels.eq(baseline).to(DType.F64);
let matches = matched.sum();
let misses = matches.rsub(total);
let rate = matches.div(total);
let parts = torch.list().add(matches.reshape(1)).add(misses.reshape(1));
let answer = torch.cat(parts.add(rate.reshape(1)), 0);
out.set("predictions", pred).set("matched", matched).set("summary", answer);
{
"predictions": [
0,
0,
0,
0,
0
],
"matched": [
1,
1,
0,
1,
1
],
"summary": [
4,
1,
0.8
]
}Your turn
Fix the summary tensor [matches, misses, match_rate] so matches counts how many rows equal baseline. The starter sums labels directly, which counts positive rows (1) instead of matched rows (4) when baseline is 0. Check tests new tables under both baseline = 0 and baseline = 1.

let baseline = float(int(scene.parameter("baseline", 0.0, 0.0, 1.0, 1.0)));
let labels = input.select(1, 1);
let n = labels.numel();
let total = float(n);
let pred = torch.full(n, baseline).to(DType.F64);
let matched = labels.eq(baseline).to(DType.F64);
let matches = labels.sum();
let misses = matches.rsub(total);
let rate = matches.div(total);
let parts = torch.list().add(matches.reshape(1)).add(misses.reshape(1));
let answer = torch.cat(parts.add(rate.reshape(1)), 0);
out.set("predictions", pred).set("matched", matched).set("summary", answer);
{
"predictions": [
0,
0,
0,
0,
0
],
"matched": [
1,
1,
0,
1,
1
],
"summary": [
1,
4,
0.2
]
}Return [matches, misses, match_rate] for the constant baseline rule by summing the equality indicator where true labels match baseline.
Read the result carefully
An eighty-percent match rate sounds respectable until you compare it with this zero-effort benchmark. On a table that is eighty percent negative, any model scoring 0.8 or lower in overall match rate has not beaten a rule that never reads the input column. Equally important, the Always-N baseline achieves 0.8 by missing one hundred percent of the positive class, which is why overall match rate alone cannot certify a detector.
Recap
- The Always-N baseline predicts
0on every row without reading any feature or score. - On four negatives and one positive, Always-N gets
4matches,1miss, and a0.8match rate. - Compare every learned classifier against the majority-class baseline before claiming useful skill.