skip to content

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

  1. Describe the four risk bands of a gate and the action of each band.
  2. Calculate the false-accept rate and the false-reject rate of one threshold on labeled records.
  3. Give each rate with a Wilson interval, and say what the interval does not cover.
  4. 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:

bandaction
LowPass
MediumAct quietly
HighShow a challenge
Very highBlock

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:

  1. Write the limit: the highest false-reject rate that you accept, for example 10%.
  2. 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 sidedetection 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

optiongaincostwhen it is correct
Keep the default threshold of a productNo workThe default does not know your traffic or your costsNever as the final value
A false-reject limit firstReal users get a stated limitThe false-accept rate can be highWhen the cost of a lost user is high
Lowest total cost with a weight for each errorOne rule for both errorsThe weights are a guess until you measure themWhen you know the cost of each error
A quiet band under the challenge bandLess feedback to the automation sideMore states to testFor each gate with a visible challenge
Intervals on web sessionsThe interval is honest when web sessions repeatIt must have many web sessionsWhen 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 bands and actions of one gate, with the error of each band
risk band (example range)actionwhat the client seeserror when the class is wrong
Low: 0.00 to 0.29PassNothingAn automated client is a false accept
Medium: 0.30 to 0.59Act quietlyNothing, or a short delayA small cost for a person
High: 0.60 to 0.84ChallengeA visible taskA person is a false reject
Very high: 0.85 to 1.00BlockA refusalA person is a false reject
The ranges are example values. Only the challenge threshold, here 0.60, is the subject of this page.source: My model of the risk bands and the actions of a gate

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.

m39-x03-threshold.tstypescript

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.510

The 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

reject rate and false-accept rate against the threshold, score only72.83%0%4.65%49.1%0.050.10.150.20.250.30.350.40.450.50.550.60.650.70.750.80.850.90.95%1. baseline reject rate2. false-accept rate

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
reject rate and false-accept rate against the threshold, score only
seriesthreshold%interval
baseline reject rate0.0572.8367.18 to 77.83 (level 0.95)
baseline reject rate0.172.8367.18 to 77.83 (level 0.95)
baseline reject rate0.1572.8367.18 to 77.83 (level 0.95)
baseline reject rate0.272.8367.18 to 77.83 (level 0.95)
baseline reject rate0.2572.8367.18 to 77.83 (level 0.95)
baseline reject rate0.372.8367.18 to 77.83 (level 0.95)
baseline reject rate0.3572.8367.18 to 77.83 (level 0.95)
baseline reject rate0.451.745.7 to 57.65 (level 0.95)
baseline reject rate0.4551.745.7 to 57.65 (level 0.95)
baseline reject rate0.551.745.7 to 57.65 (level 0.95)
baseline reject rate0.5528.6823.57 to 34.4 (level 0.95)
baseline reject rate0.628.6823.57 to 34.4 (level 0.95)
baseline reject rate0.6528.6823.57 to 34.4 (level 0.95)
baseline reject rate0.728.6823.57 to 34.4 (level 0.95)
baseline reject rate0.753.772.06 to 6.81 (level 0.95)
baseline reject rate0.83.772.06 to 6.81 (level 0.95)
baseline reject rate0.8500 to 1.43 (level 0.95)
baseline reject rate0.900 to 1.43 (level 0.95)
baseline reject rate0.9500 to 1.43 (level 0.95)
false-accept rate0.054.653.81 to 5.67 (level 0.95)
false-accept rate0.14.653.81 to 5.67 (level 0.95)
false-accept rate0.154.653.81 to 5.67 (level 0.95)
false-accept rate0.24.653.81 to 5.67 (level 0.95)
false-accept rate0.254.653.81 to 5.67 (level 0.95)
false-accept rate0.34.653.81 to 5.67 (level 0.95)
false-accept rate0.359.418.21 to 10.77 (level 0.95)
false-accept rate0.49.468.25 to 10.82 (level 0.95)
false-accept rate0.459.468.25 to 10.82 (level 0.95)
false-accept rate0.59.468.25 to 10.82 (level 0.95)
false-accept rate0.5514.6613.18 to 16.28 (level 0.95)
false-accept rate0.619.4717.79 to 21.26 (level 0.95)
false-accept rate0.6519.4717.79 to 21.26 (level 0.95)
false-accept rate0.724.2222.4 to 26.15 (level 0.95)
false-accept rate0.7531.3329.33 to 33.4 (level 0.95)
false-accept rate0.838.2436.13 to 40.39 (level 0.95)
false-accept rate0.8544.1942.03 to 46.38 (level 0.95)
false-accept rate0.945.543.32 to 47.69 (level 0.95)
false-accept rate0.9549.146.91 to 51.29 (level 0.95)
Scripted test clients on my own lab gate. Bands are 95% Wilson intervals on navigations. They ignore that one web session has many navigations. The reject rate is for slow scripted clients, not for real users.

failure modes

problemcausecorrection
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

  1. 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.

  2. 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?

    1. 3%
    2. 85%
    3. 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%.

  3. Each web session of a lab set gives many records. You give a Wilson interval on records. What is the problem?

    1. The interval counts each record as independent, thus it is too narrow.
    2. The Wilson interval is not valid near 0 or 1.
    3. 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.

  4. 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?

    1. Threshold B, because its false-accept rate is lower
    2. Threshold A, because only it is in the limit
    3. 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.

classscores
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
  1. Calculate the false-reject rate and the false-accept rate at the threshold 0.5.
  2. Calculate the same two rates at the threshold 0.7.
  3. Select the threshold of the two that keeps the false-reject rate at 10% or less.
  4. 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

  1. My model of the risk bands, the quiet action, and the selection of a threshold, 2026-11 (not public).