A probability becomes an action through policy
A threshold is the bridge from a probability to product behavior. Jev can answer "Is this message asking for a refund?" with a Noul value, but code still decides whether to tag, review, or ignore the message. threshold: a value at which application policy changes the action it takes belongs to the application. A value such as 0.85 is a teaching example, not a TypeSafe default.
Choice and Score return a full distribution and a confidence value from 0 to 1 derived from the shape of that distribution. Concentrated distributions have higher confidence; flatter distributions have lower confidence. Noul returns only its yes probability.
TypeSafe does not publish the exact confidence formula. It must not be reverse-engineered from a few examples or described as entropy, margin, top probability, or probability of correctness without evidence. Developers can compute a different statistic from the full distribution if their use case requires it.
Confidence is not a universal probability that the answer is correct, does not include retrieval correctness or downstream policy correctness, and does not authorize an action. A low Choice confidence may mean several options are similarly plausible; a low Score confidence may mean levels overlap, the state is missing evidence, or the question mixes dimensions. A harmless preference selection may remain useful at low confidence.
Calibration is a cohort property. If predictions assigned about 0.8 are calibrated, roughly 80% of the corresponding outcomes should occur across a suitable group of cases. It is not a guarantee about one prediction.
Calibration and discrimination answer different questions. Discrimination asks whether positive examples tend to receive larger values than negative examples. Calibration asks whether numeric values match observed frequencies. Measure both before selecting a threshold.
Start by naming the consequences. A false positive tags a message that did not request a refund. false negative: a case the policy treats as negative even though the labeled outcome is positive leaves a real request untagged. Those mistakes have different costs. Reversible routing can tolerate more errors than transferring money, which should remain behind trusted records, deterministic authorization, and human review.
Trace this example from input to result
Customer choice
A customer submits a ticket asking to reverse a duplicate charge.
Request or event
The router builds state and asks a refund-intent Noul question.
Backend behavior
Jev returns a Noul value; versioned application policy compares it with action and review thresholds.
Customer sees
The ticket enters billing, general review, or ordinary triage. No refund is issued by the model.
Diagnostic reasoning
Replay the exact state, question version, returned model, value, threshold, and downstream route before blaming the model.
| Customer sees | Application does | Jev returns |
|---|---|---|
| A billing specialist receives the ticket | Applies a measured threshold and checks account facts | A Noul value for refund intent |
Measure mistakes on labeled cases
labeled dataset: representative examples paired with outcomes established by a documented review process lets the team measure policy rather than guess. Labels need instructions too: reviewers must distinguish "refund requested" from "customer asks why a charge exists." Disagreement should be recorded instead of forced into false certainty.
For every candidate threshold, calculate true positives, false positives, true negatives, and false negatives. Precision asks how often an automatically tagged case is truly positive; recall asks how much of the labeled positive set the policy captures. Neither chooses the policy alone. The example code assigns synthetic costs of 1 unit for unnecessary review and 5 for a missed time-sensitive request. These are teaching values, not observed Jev performance.
type Row = { probability: number; label: boolean };
function evaluate(rows: Row[], threshold: number) {
let fp = 0, fn = 0, tp = 0, tn = 0;
for (const row of rows) {
const predicted = row.probability >= threshold;
if (predicted && row.label) tp++;
else if (predicted) fp++;
else if (row.label) fn++;
else tn++;
}
return { tp, fp, fn, tn, syntheticCost: fp + 5 * fn };
}
Use a representative, time-bounded dataset and preserve the exact state, question, model, and label versions. Sweep candidate thresholds on development data, compare precision, recall, review coverage, and expected cost, then confirm the selected policy on a held-out set. Selecting and reporting on the same cases overstates quality.
Explore a threshold policy
Eight synthetic labeled cases. These are teaching fixtures, not Jev predictions or a calibration study. Positive means route to the priority queue; uncertain cases go to review.
Cost units: false positive 9, false negative 2, review 0.5. Review is assumed correct here solely to simplify the exercise. Production review has its own errors and costs.
Counts: 2 true positives, 1 false positives, 0 false negatives, 2 true negatives, 3 reviews. A wider review band changes which cases remain; it does not establish a guarantee about future risk.
The simulator uses eight synthetic cases to show how a threshold changes true positives, false positives, false negatives, review coverage, and a chosen cost function. It is a policy exercise, not a Jev calibration benchmark or evidence about live model quality.
Add abstention and review bands
abstention: a policy decision not to automate because available evidence is insufficient for the action is application behavior. A policy might tag values at or above 0.85, treat values below 0.35 as negative, and send the middle band to review. The middle is not a new Noul category.
Missing account evidence should follow a separate path. A high intent value cannot prove the charge exists or the requester owns the account. Ask for clarification when the message lacks the relevant record; use human review when evidence exists but risk remains high. Measure automation coverage alongside error rates because a policy can appear safe by abstaining on nearly everything.
Review capacity is part of the policy. If the middle band sends more work than people can inspect before the service target expires, caution creates a queueing failure. Plot coverage against selective risk and choose a point that fits both error tolerance and staffed capacity.
A threshold creates too many billing tickets
False-positive rate rose after policy 7 changed 0.90 to 0.70Compare the same labeled replay under both policies. If the probabilities are unchanged but routes differ, the smallest supported boundary is policy. Restore the previous threshold while reviewing the cost assumptions. If distributions changed too, separate model, question, and traffic changes before choosing a fix.
Check subgroups and changing costs
Aggregate results can hide concentrated harm. Evaluate relevant subgroups such as ticket language, product area, message length, and whether account facts were present. Choose groups because the workflow makes them meaningful, not because a dashboard offers them. Small samples need uncertainty intervals and careful interpretation.
Do not respond to a weak subgroup result by inventing a different threshold from a handful of examples. First check label consistency, sample size, state construction, and whether the question has the same meaning for the group. A threshold can hide a retrieval defect without repairing it. When a different policy is justified, record why the group is operationally meaningful and test the resulting review load.
Monitor label prevalence, score distributions, abstention rate, reviewer overturns, and final actions. A model upgrade, question edit, retrieval change, seasonal traffic shift, or new refund policy can invalidate the old threshold. Re-run the labeled evaluation and require an explicit policy version in logs.
Write a threshold policy
Your answers stay in this browser. Write enough that another engineer could continue the investigation.
Dig deeperOptimize expected loss without hiding assumptions+
Expected-loss optimization multiplies measured outcome frequency by a cost matrix. The arithmetic is simple; agreeing on costs is not. Include review capacity, delayed resolution, customer harm, and irreversible actions. Test sensitivity across plausible costs instead of presenting one optimum as objective truth. Calibration and discrimination are separate: a ranking can separate cases well while its numeric probabilities remain miscalibrated.
TypeSafe calls its training approach "Reinforcement Learning for Calibrated Decisions" (RLCD). Public materials describe the goal but do not provide enough detail to independently assess the algorithm. Treat RLCD as vendor terminology and validate probability behavior on the target workflow. Reliability diagrams, Brier score, log loss, and carefully reported ECE can help; record sample counts and binning because calibration estimates depend on both.