BrainState leaves the Personalizer through a gate: the fixed checks of DecisionConfig, or a certificate calibrated on held-out trials. A fixed check is a number you chose. A certificate is a promise with conditions written on it. This page is about the second kind: how to get one, what it guarantees, and where it stops.
The page is about
nimbus-bci 0.10.0. The conformal gate arrived in 0.9.0; the risk gate, the certificate as the default on four heads, and the gates’ own verdicts on every trial arrived in 0.10.0.Three ways to calibrate a gate
All three are fitted on a held-out set the head never trained on. An in-sample set inflates every one of them.
A certificate decides on four heads
Since 0.10.0, onNimbusProbit, NimbusLDA, NimbusQDA and NimbusSoftmax, a fresh certificate replaces the confidence floor and the entropy ceiling: the shipped path accepts exactly what the certificate accepts. fit_calibrated fits the risk gate on these heads unless you name another method.
- Without a certificate, nothing changes. The fixed gate stays, every
BrainStatecarriesextras["gate_calibrated"] = False, and a warning says so once per process. NimbusFusionis unchanged.fit_calibratedstill pins an accept rate on it, and a certificate is stacked on the fixed checks.- A certificate is void after any update of the head.
Personalizer.risk_staleandPersonalizer.conformal_staleflip toTrue, the fixed checks stand again, and the certificate must be calibrated afresh. - It costs labelled trials. At least nine for
alpha = 0.1, in practice 8–12 per class. At 4 trials per class on two classes nothing is certified.
Why the default changed: the fixed gate is restrictive and not safe. Behind
NimbusProbit it rejected 21–48 % of the trials and still sent 8–18 % wrong commands; behind QDA it sent 83–99 % of the trials with 20–37 % wrong. The risk gate kept its promise behind every head. The numbers are below, under What is measured.The conformal gate: a certified set
P(y_true ∈ S(x)) ≥ 1 − alpha, marginallyWith the default
max_set_size=1, an accepted trial’s set is exactly the top class, so P(accepted AND wrong) ≤ alpha: the probability that an emitted command should have been rejected is bounded.
What is not guaranteed. The conditional accuracy of accepted trials. It is measured (evaluate_personalizer(...).conformal["accuracy_on_accepted"]), never claimed. The accept rate at a given alpha is whatever falls out for your trunk and is reported, not pinned.
max_set_size > 1accepts narrow sets for two-stage interfaces, such as 2 of 8 speller classes.randomized=True(default) is seeded: a batch is deterministic for fixed inputs, and a live loop advances the stream one draw per trial.randomized=Falseis the conservative variant — no randomness, weakly larger sets, the same bound.- The fitted gate round-trips through
save/loadand the profile (export_profile→from_profile).p.conformal_gate_.set_alpha(0.05)re-quantiles a loaded profile without the calibration data.
The risk gate: a bound on wrong commands
The conformal gate keeps its promise by refusing aboutalpha of the trials, confident or not. The risk gate promises what a command interface asks for instead.
floor(alpha * (n + 1) - 1) wrong calibration trials would pass it. The gate is deterministic: predict_one and a batch agree.
What is guaranteed. The share of new trials that end in a wrong command is at most alpha, in expectation over the calibration draw, for independent trials from one distribution. It is not a coverage statement, and not a bound on the error rate among accepted trials as such. The gate’s verdict on each trial is BrainState.extras["risk_passed"].
Both gates can be calibrated together; a trial must then pass both. With fewer than ceil(1 / alpha) - 1 held-out trials nothing is certified: the bar is infinite and a UserWarning says so.
The pinned rate and its entropy ceiling
calibrate_decision_gate — or fit_calibrated(..., method="accept_rate") — tunes the confidence floor so that the target share of the held-out trials is accepted. It promises the rate and nothing else.
On three or more classes the gate is a confidence floor under an entropy ceiling of 0.75 * log2(K) bits, and a diffuse posterior fails the ceiling first. When fewer than the target share of the held-out trials pass the ceiling, no floor can reach the target. The pin then keeps the ceiling (entropy="keep", the default): it installs the floor, warns cannot reach target_accept, and reports the maximum it can reach as achieved_accept.
entropy="yield" sends more and promises only the rate; acc_accepted is the accuracy it carries. Whether that trade is worth it is the application’s call — in typing, a wrong character is cheap to fix; where an error is costly, it is not. The ceiling is yours to set as well: DecisionConfig(entropy_threshold=...) in bits, None for the class-count rule. On the four heads above, fit_calibrated no longer pins a rate at all: pass method="accept_rate".
Each gate’s own verdict on every trial
A loop that runs both gates can audit each promise on its own:prediction_set stays the set after both gates. Decisions are unchanged by these keys.
A live loop draws per trial.
predict_one — and any predict call that holds exactly one trial — takes the next draw of the conformal gate’s stream, exactly as each row of a batch takes its own. Scoring the same trial twice can return different sets. The stream position is saved with the profile (live_draws).Deciding inside a set
The gate certifies a set; a command is one symbol. For a speller,choose_within_sets(posteriors, sets, log_prior) picks the member a language model finds most plausible after what was already typed, and spell_with_prior threads the chosen prefix through a sequence. The choice is confined to the set and abstains on an empty one, or on one whose every member the prior forbids.
It raises the information rate, not the guarantee: a pick is right when the true label is in the set — bounded — and ranks first inside it — not bounded.
What is measured
Preregistered cells, read once each, offline on public corpora. “Wrong” is wrong commands as a share of all trials. Within a session (BNCI2015-001, twelve subjects, the head on 4–20 trials per class, every calibrated gate fitted on a second set of as many held-out trials):
The risk gate kept its promise in all 36 cells.
In the next session — the same certificate, the head and the gate’s trials drawn from one session, every trial of the next session read; three public corpora, thirty subjects:
The promise held in 34 of 36 cells; the risk gate sent 16–71 % of the next session’s trials. It is a corpus’s mean, not a subject’s: one subject’s gate sent 0.26 wrong.
What none of this promises
- Nothing across a session change. Exchangeability is the load-bearing assumption. Under drift — a session change, a cap change, fatigue — a guarantee is void. Recalibrate on the session you type in. The next-session numbers above are a reading, not a promise.
- Nothing per user or per session. The guarantee is marginal, an average over trials and draws. A 40-trial session’s coverage moves with a standard deviation of 0.04–0.07 over the conformal gate’s draws.
- Nothing after the head changes. Any update of the head voids the certificate; the staleness flags say so on every trial.
- Nothing about accuracy. A head with a calibrated gate is not a more accurate head. On covariance features a plain logistic regression is as accurate as every head measured.
- One level and one target were measured:
alpha = 0.1andtarget_accept = 0.7.
Next read
SSVEP
Filter-bank CCA, TRCA and TDCA, and the gates on them.
BrainState
The fields every trial carries, including each gate’s verdict.
Evidence
How the numbers on this page were produced, and their boundaries.
Changelog
Release and upgrade notes, newest first.