Skip to content

solvi.core.deciders.gate

What decides alone: the act features, thresholds, promises (act_guard).

Part of solvi.core.deciders, which re-exports every name; import from there.

What decides alone: the act features, thresholds, promises (act_guard) and groups; inputs as Facts. (Part of solvi.core.deciders, which re-exports every name.)

GroupBy

GroupBy(by)

Which group an input belongs to, for thresholds per group (act_guard(groups=...)): a fact name ("domain"), a list of fact names — a hierarchy, top first (["domain", "task"]) — or a function whose parameters are fact names and which returns a group or a path (domain, task). A function with one parameter also takes an input that is not given as facts (a text or a state): it is called with the input itself. A state (dict) input gives facts by its keys.

path

path(vals=None, raw=None)

The input's group path (a tuple), or None when the input does not give it.

Facts

Bases: dict

An example input given as facts by name (Facts(email=..., tier=...)): each part reads its own facts, a route's predicates and a grouping (act_guard(groups=...)) read theirs. Any other input is the one input every part reads (a text or a state).

group_name

group_name(path)

A group path as people read it: "billing / refunds"; the whole stream: "(the rest of the stream)".

group_record

group_record(g, path, node, info)

A decision's guarantee under thresholds per group: the part's promise, the input's group, the group whose threshold applied (its own, or a parent's when the group had too few examples), that threshold and its examples.

one_source

one_source(ds, who='the calibration examples')

The one source of the decisions' probabilities (see confidence_source; None when no decision names one). Raises ValueError when log-probabilities and written numbers are mixed: they are two scales (a token probability near 1 against a stated 0.85-0.95), and one threshold over both answers alone by which server happened to reply.

guard_promise

guard_promise(risk, error, answered=True)

act_guard's promise in words, with the error among the answers given alone on the calibration examples.

no_separation

no_separation(sig, ok, name, error, base, who='')

A warning when the signal does not tell right answers from wrong ones on the calibration examples (one-sided Mann-Whitney test of its AUROC against chance at the 5% level: solvi.core.calibration.separation), else None — tested only with at least SEPARATION_MIN right and as many wrong examples (fewer cannot tell). The promise still holds — by escalating, not by choosing: what is answered alone is wrong about as often as everything.

act_features

act_features(sp, d, act_logit)

The features of the act calibrator (ACT_FEATURES) for a calibrated decision: confidence (the decision's calibrated confidence: the top probability; multi-label: the least certain option's max(p, 1 − p)), margin (top − second probability; multi-label: the smallest |2p − 1|), entropy (of the probabilities, nats; multi-label: the mean binary entropy), act_logit (raw), n_options, kind= (1 / 0).

decision_of

decision_of(catalog, question)

The DecisionPart behind a question's answer: its rule is a decision, or a rule that only passes a decided fact on (e.g. def team(route): return route). → the part or None.