design and build a challenge that survives a solver · lesson 2 of 7 · sources checked 2026-11-22
the score and the threshold
This lesson sets the threshold of the challenge band from labeled lab records and the cost of each error, with intervals.
purpose
A gate does not see a person or a bot. It sees a number, and the threshold decides how many real users it stops and how many automated clients it passes. You must set that threshold from your own labeled traffic and from the cost of each error, not from a default.
objectives
- Describe the four risk bands of a gate and the action of each band.
- Calculate the false-accept rate and the false-reject rate of one threshold on labeled records.
- Give each rate with a Wilson interval, and say what the interval does not cover.
- Select a threshold from a limit for the false-reject rate.
new terms
- risk band
- A range of the risk score that the gate maps to one action.
- false-accept rate
- The share of the automated records of a labeled set that a gate passes.
- false-reject rate
- The share of the legitimate records of a labeled set that a gate challenges or blocks. On real traffic, it is the false-positive rate.
how it works
The gate reads a risk score from the other checks of Why perception is not enough (not yet published). On this page, a high score means more risk. A product can use the other direction. The polarity of each score is in Score polarity, thresholds, and silence (not yet published).
The gate maps the score to a risk band. Each band has one action:
| band | action |
|---|---|
| Low | Pass |
| Medium | Act quietly |
| High | Show a challenge |
| Very high | Block |
The response policy for all actions is in The response policy: thresholds, the challenge gate, and the cost of a false positive (not yet published). Here I set one value only: the threshold of the challenge band.
act quietly
A quiet action changes the cost of the request, but the client sees no change of the page. For example, a score of 0.45 is in the medium band of the diagram. The gate adds a short proof of work (PoW) step and records the request. A person sees a short delay.
An automated client gets no clear sign that the gate scored it. Thus the automation side learns less from each request. It sees only the action, never the threshold.
two error rates
Each record of a labeled test set has a score and a class: legitimate or automated. One threshold gives two error rates:
- The false-accept rate is the share of automated records with a score under the threshold. The gate passes them.
- The false-reject rate is the share of legitimate records with a score at or over the threshold. The gate challenges or blocks them.
For example, a set has 10 automated records, and 2 of them have a score under 0.5. At the threshold 0.5, the false-accept rate is 2 of 10, or 20%.
On real traffic, the false-reject rate of real users is the false-positive rate of the gate. A lab set does not hold real users. Thus the lab rate shows how the gate treats the legitimate class of the lab, not how it treats real users.
intervals
A small set gives a wide range for each rate. Give each rate with a Wilson interval. For example, 1 of 10 is 10%, and its 95% Wilson interval is 1.8% to 40.4%.
The Wilson interval counts each record as independent. But one web session can give many records, and records of one web session are not independent. Thus an interval on web sessions is wider than an interval on records. When the set has many records for each web session, give the interval on web sessions too.
select the threshold
Write the cost of each error before you look at the rates. A false reject costs a real user time, and it can lose the user. A false accept lets an automated client pass this gate.
Then select the threshold in two steps:
- Write the limit: the highest false-reject rate that you accept, for example 10%.
- Take the threshold with the lowest false-accept rate in that limit.
The code example does these two steps on invented scores. The exercise does them by hand.
the lab chart
The chart in the section "Data" shows the two rates against the threshold. As the threshold goes up, the gate rejects fewer clients of the baseline class, and it passes more automated clients. The rates change in steps, because the score of that gate has few levels.
The baseline class is a set of slow scripted clients. Thus the chart gives no false-reject rate of real users. The bands of the chart are intervals on navigations. An interval on web sessions is wider.
the two sides
| automation side | detection side |
|---|---|
| The automation side does not see the threshold. It sees only the action: a pass, a quiet step, or a challenge. A tool that reads a score must know its polarity. | Set the threshold from your own traffic and from the cost of each error. Act quietly in the band under the challenge band, so that the automation side gets less feedback. |
design decisions
| option | gain | cost | when it is correct |
|---|---|---|---|
| Keep the default threshold of a product | No work | The default does not know your traffic or your costs | Never as the final value |
| A false-reject limit first | Real users get a stated limit | The false-accept rate can be high | When the cost of a lost user is high |
| Lowest total cost with a weight for each error | One rule for both errors | The weights are a guess until you measure them | When you know the cost of each error |
| A quiet band under the challenge band | Less feedback to the automation side | More states to test | For each gate with a visible challenge |
| Intervals on web sessions | The interval is honest when web sessions repeat | It must have many web sessions | When one web session gives many records |
diagram
A matrix of four risk bands with example ranges. Low, 0.00 to 0.29: pass, the client sees nothing, an automated client here is a false accept. Medium, 0.30 to 0.59: act quietly. High, 0.60 to 0.84: challenge, a person here is a false reject. Very high, 0.85 to 1.00: block.
| risk band (example range) | action | what the client sees | error when the class is wrong |
|---|---|---|---|
| Low: 0.00 to 0.29 | Pass | Nothing | An automated client is a false accept |
| Medium: 0.30 to 0.59 | Act quietly | Nothing, or a short delay | A small cost for a person |
| High: 0.60 to 0.84 | Challenge | A visible task | A person is a false reject |
| Very high: 0.85 to 1.00 | Block | A refusal | A person is a false reject |
code example
The example selects a threshold for a limit of the false-reject rate. The scores are invented. No score comes from a real product or a real person.
Select a threshold from invented labeled scores for a limit of the false-reject rate, and print both rates with Wilson intervals.
// INVENTED scores for this example. A high score means more risk.
const LEGITIMATE = [0.05, 0.10, 0.12, 0.20, 0.25, 0.30, 0.35, 0.45, 0.55, 0.72];
const AUTOMATED = [0.30, 0.48, 0.62, 0.66, 0.74, 0.80, 0.85, 0.88, 0.93, 0.97];
const LIMIT_FALSE_REJECT = 0.10; // example limit
const Z = 1.96; // 95% interval
function wilson(k: number, n: number): [number, number] {
const p = k / n;
const d = 1 + (Z * Z) / n;
const c = (p + (Z * Z) / (2 * n)) / d;
const h = (Z * Math.sqrt((p * (1 - p)) / n + (Z * Z) / (4 * n * n))) / d;
return [Math.max(0, c - h), Math.min(1, c + h)];
}
// Rejected: legitimate records at or over t. Accepted: automated records under t.
function rates(t: number): [number, number] {
const rejected = LEGITIMATE.filter((s) => s >= t).length;
const accepted = AUTOMATED.filter((s) => s < t).length;
return [rejected, accepted];
}
let best: { t: number; rejected: number; accepted: number } | null = null;
for (let i = 1; i < 20; i++) {
const t = Math.round(i * 5) / 100;
const [rejected, accepted] = rates(t);
if (rejected / LEGITIMATE.length <= LIMIT_FALSE_REJECT) {
if (best === null || accepted < best.accepted) best = { t, rejected, accepted };
}
}
if (best === null) {
console.log("no threshold meets the limit");
} else {
const [frLo, frHi] = wilson(best.rejected, LEGITIMATE.length);
const [faLo, faHi] = wilson(best.accepted, AUTOMATED.length);
console.log(`threshold ${best.t}`);
console.log(`false-reject rate ${best.rejected}/${LEGITIMATE.length}, 95% interval ${frLo.toFixed(3)} to ${frHi.toFixed(3)}`);
console.log(`false-accept rate ${best.accepted}/${AUTOMATED.length}, 95% interval ${faLo.toFixed(3)} to ${faHi.toFixed(3)}`);
}output
The selected threshold, then each rate with its count and its 95% Wilson interval.
threshold 0.6
false-reject rate 1/10, 95% interval 0.018 to 0.404
false-accept rate 2/10, 95% interval 0.057 to 0.510The output shows the threshold 0.6. At this threshold, 1 of 10 legitimate records is a false reject, in the limit of 10%. 2 of 10 automated records are a false accept. Each interval is wide, because each class has only 10 records.
data
reject rate and false-accept rate against the threshold, score only
status of this figure: measured by me
band: interval, level 0.95
source: Lab result of this course: my own lab gate, one run, labeled scripted classes; date 2026-11-13; sample of 2,263; condition: n is the number of navigations of one run: 265 of the baseline classes and 1,998 of the other classes (derived sum). The classes are scripted, with correct labels.
data table
| series | threshold | % | interval |
|---|---|---|---|
| baseline reject rate | 0.05 | 72.83 | 67.18 to 77.83 (level 0.95) |
| baseline reject rate | 0.1 | 72.83 | 67.18 to 77.83 (level 0.95) |
| baseline reject rate | 0.15 | 72.83 | 67.18 to 77.83 (level 0.95) |
| baseline reject rate | 0.2 | 72.83 | 67.18 to 77.83 (level 0.95) |
| baseline reject rate | 0.25 | 72.83 | 67.18 to 77.83 (level 0.95) |
| baseline reject rate | 0.3 | 72.83 | 67.18 to 77.83 (level 0.95) |
| baseline reject rate | 0.35 | 72.83 | 67.18 to 77.83 (level 0.95) |
| baseline reject rate | 0.4 | 51.7 | 45.7 to 57.65 (level 0.95) |
| baseline reject rate | 0.45 | 51.7 | 45.7 to 57.65 (level 0.95) |
| baseline reject rate | 0.5 | 51.7 | 45.7 to 57.65 (level 0.95) |
| baseline reject rate | 0.55 | 28.68 | 23.57 to 34.4 (level 0.95) |
| baseline reject rate | 0.6 | 28.68 | 23.57 to 34.4 (level 0.95) |
| baseline reject rate | 0.65 | 28.68 | 23.57 to 34.4 (level 0.95) |
| baseline reject rate | 0.7 | 28.68 | 23.57 to 34.4 (level 0.95) |
| baseline reject rate | 0.75 | 3.77 | 2.06 to 6.81 (level 0.95) |
| baseline reject rate | 0.8 | 3.77 | 2.06 to 6.81 (level 0.95) |
| baseline reject rate | 0.85 | 0 | 0 to 1.43 (level 0.95) |
| baseline reject rate | 0.9 | 0 | 0 to 1.43 (level 0.95) |
| baseline reject rate | 0.95 | 0 | 0 to 1.43 (level 0.95) |
| false-accept rate | 0.05 | 4.65 | 3.81 to 5.67 (level 0.95) |
| false-accept rate | 0.1 | 4.65 | 3.81 to 5.67 (level 0.95) |
| false-accept rate | 0.15 | 4.65 | 3.81 to 5.67 (level 0.95) |
| false-accept rate | 0.2 | 4.65 | 3.81 to 5.67 (level 0.95) |
| false-accept rate | 0.25 | 4.65 | 3.81 to 5.67 (level 0.95) |
| false-accept rate | 0.3 | 4.65 | 3.81 to 5.67 (level 0.95) |
| false-accept rate | 0.35 | 9.41 | 8.21 to 10.77 (level 0.95) |
| false-accept rate | 0.4 | 9.46 | 8.25 to 10.82 (level 0.95) |
| false-accept rate | 0.45 | 9.46 | 8.25 to 10.82 (level 0.95) |
| false-accept rate | 0.5 | 9.46 | 8.25 to 10.82 (level 0.95) |
| false-accept rate | 0.55 | 14.66 | 13.18 to 16.28 (level 0.95) |
| false-accept rate | 0.6 | 19.47 | 17.79 to 21.26 (level 0.95) |
| false-accept rate | 0.65 | 19.47 | 17.79 to 21.26 (level 0.95) |
| false-accept rate | 0.7 | 24.22 | 22.4 to 26.15 (level 0.95) |
| false-accept rate | 0.75 | 31.33 | 29.33 to 33.4 (level 0.95) |
| false-accept rate | 0.8 | 38.24 | 36.13 to 40.39 (level 0.95) |
| false-accept rate | 0.85 | 44.19 | 42.03 to 46.38 (level 0.95) |
| false-accept rate | 0.9 | 45.5 | 43.32 to 47.69 (level 0.95) |
| false-accept rate | 0.95 | 49.1 | 46.91 to 51.29 (level 0.95) |
failure modes
| problem | cause | correction |
|---|---|---|
| The gate stops many real users. | The threshold is a default of a product, not a value from your traffic. | Set the false-reject limit first, and select the threshold from your labeled records. |
| A rate of 0% looks safe. | The set is small, and nobody gave the interval. | Give each rate with a Wilson interval. |
| The interval is too narrow. | Many records come from one web session, and the interval counts each record as independent. | Give the interval on web sessions too. |
| The automation side finds the threshold. | Each score over the threshold gets a visible challenge at once. | Put a quiet band under the challenge band. |
| A lab reject rate stands as the rate of real users. | The legitimate class of the lab is a set of scripted clients. | Say which class each rate is for. Measure real users in your own traffic. |
check questions
Describe the four risk bands of a gate and the action of each band.
sample answer
The low band passes the request. The medium band acts quietly, for example with a short proof-of-work step and a record. The high band shows a challenge. The very high band blocks the request.
A labeled set has 20 legitimate records. At one threshold, 3 of them have a score at or over the threshold. A high score means more risk. What is the false-reject rate?
- 3%
- 85%
- 15%
answer
c. 15%
The false-reject rate is the share of legitimate records that the gate challenges or blocks: 3 of 20 is 15%.
Each web session of a lab set gives many records. You give a Wilson interval on records. What is the problem?
- The interval counts each record as independent, thus it is too narrow.
- The Wilson interval is not valid near 0 or 1.
- The interval is too wide, because it counts web sessions.
answer
a. The interval counts each record as independent, thus it is too narrow.
Records of one web session are not independent. An interval on web sessions is wider and more honest.
Your limit for the false-reject rate is 5%. Threshold A gives a false-reject rate of 4% and a false-accept rate of 30%. Threshold B gives 8% and 12%. Which threshold do you select?
- Threshold B, because its false-accept rate is lower
- Threshold A, because only it is in the limit
- Neither, because each threshold has errors
answer
b. Threshold A, because only it is in the limit
First keep only the thresholds in the limit of the false-reject rate. Then take the lowest false-accept rate of them. Only threshold A is in the limit.
exercise
exercise Do this task on paper. Use the 20 synthetic records of a lab gate of your own. A high score means more risk. The gate challenges a score at or over the threshold.
| class | scores |
|---|---|
| Legitimate (10 records) | 0.05, 0.10, 0.12, 0.20, 0.25, 0.30, 0.35, 0.45, 0.55, 0.72 |
| Automated (10 records) | 0.30, 0.48, 0.62, 0.66, 0.74, 0.80, 0.85, 0.88, 0.93, 0.97 |
- Calculate the false-reject rate and the false-accept rate at the threshold 0.5.
- Calculate the same two rates at the threshold 0.7.
- Select the threshold of the two that keeps the false-reject rate at 10% or less.
- Write one reason why 10 records for each class are not sufficient.
sample answer
The answer uses the 20 synthetic records of the task.
At 0.5, two legitimate records (0.55 and 0.72) are at or over the threshold, thus the false-reject rate is 2 of 10, or 20%. Two automated records (0.30 and 0.48) are under it, thus the false-accept rate is 20%.
At 0.7, one legitimate record (0.72) is over the threshold, thus the false-reject rate is 10%. Four automated records are under it, thus the false-accept rate is 40%.
Only 0.7 keeps the false-reject rate in the limit of 10%. The cost is a false-accept rate of 40%. The 95% Wilson interval of 1 of 10 is 1.8% to 40.4%. Thus the real false-reject rate can be much higher than the limit.
sources
- My model of the risk bands, the quiet action, and the selection of a threshold, 2026-11 (not public).