Skip to main content
GET
Recommend a threshold for a precision or recall target

Authorizations

Authorization
string
header
required

An organization API key. Keys carry a role (read_write or read_only) and may be restricted to a namespace prefix such as acme/*, or to one namespace such as acme/prod/tenant_1. A prefix matches on a / boundary: acme/prod/tenant_1* covers acme/prod/tenant_1 and everything under acme/prod/tenant_1/, never acme/prod/tenant_12.

Path Parameters

ns
string
required

A namespace name, or a template prefix ending in /*, with any / sent as %2F: acme%2Fprod%2Ftenant_123 or acme%2Fprod%2F*.

A namespace name, or a template prefix: a namespace path ending in /*, such as acme/prod/*, which every namespace under acme/prod/ inherits judgments from. Up to 256 bytes. Never exactly . or .., which a URL path can't carry.

Required string length: 1 - 256
Pattern: ^(?!\.\.?$)[A-Za-z0-9._:/-]+(/\*)?$
name
string
required

A judgment, attribute or threshold name. Names are path segments in field references, so they never contain ..

Required string length: 1 - 128
Pattern: ^[A-Za-z0-9_-]+$

Query Parameters

target
string
required

The metric and the value to meet, such as precision:0.9 or recall:0.8. A metric and the value to meet, such as precision:0.9 or recall:0.8.

Pattern: ^(precision|recall):(0?\.[0-9]*[1-9][0-9]*|1|1\.0+)$
option
string

Required for a choice judgment, and refused for a bool one. The option the threshold is for, such as fraud.

Minimum string length: 1
feature
string

A bool judgment with features only, and not with option: one of its features. The response is then the cut on that feature that meets the target, as a feature threshold applies it, with the recommendation on p for the same outcomes beside it.

One number the judgment records beside every answer and its fit can read. It is one of:

  • An aggregate the recipe declares, as <relation>.count, <relation>.count_where, <relation>.labelled or <relation>.<sum|avg|min|max|latest>(<path>), such as tickets.count or invoices.sum(state.amount). A min or max over an answer's p or score gives the raw extreme, whatever band the context shows; a latest over an answer's threshold reads 1 or 0. A latest over an answer's value is not a number and is invalid_request. A sum or avg over an answer's number is a feature only. A latest over a bool outcome reads 1 or 0, over a score outcome its level; over a choice outcome it is invalid_request.
  • The judged document's own value, state.<path> or attributes.<name>: a number as itself, a boolean as 1 or 0, anything else missing. It needs no relation.
  • An age in fractional days, age(created_at), age(<state or attributes path>) or age(<relation>.<latest|min|max>(<path>)) over an aggregate the recipe declares. It is measured as of the judged document's own updated_at at the revision judged, so a write to a related document never moves it, and a new revision of the judged document does. The value must be an RFC 3339 string; a number or any other value reads missing, and a later time reads negative. age(updated_at) is invalid_request: as of the judged revision it is always 0.
  • previous.p: the engine's own p the last time it judged the document with the same engine version, in the same life of the document; on a choice, its 1 - escape_p. Missing on the first judgment, after the document is created again, after the engine version changes, and on a composite, which has none. On a score it is invalid_request.
  • On a choice among candidates (options.from) only, a number per candidate, <from>.each(<path>) over the options.from relation: each candidate's state.<path> or attributes.<name>, or age(created_at), age(updated_at) or age(<state or attributes path>) of the candidate, as of the judged document's revision. It is recorded for each candidate the engine read, under the answer's candidate_features. A candidate's answers are invalid_request: keep the number on the candidate's state.

A name the recipe declares as an aggregate always reads that aggregate. A feature that reads a path an outcome rule reads, one inside the other, is invalid_request.

Pattern: ^([A-Za-z0-9_-]+\.(count|count_where|labelled|(sum|avg|min|max|latest)\((state|attributes)(\.[^.()]+)+\)|(min|max|latest)\((created_at|updated_at)\)|(sum|avg|min|max)\(answers\.[A-Za-z0-9_-]+\.(p|score|dist\.[^()]+)\)|latest\(answers\.[A-Za-z0-9_-]+\.thresholds\.[A-Za-z0-9_-]+\)|latest\(outcomes\.[A-Za-z0-9_-]+\.value\))|(state|attributes)(\.[^.()]+)+|age\((created_at|(state|attributes)(\.[^.()]+)+|[A-Za-z0-9_-]+\.(latest|min|max)\((created_at|updated_at|(state|attributes)(\.[^.()]+)+)\))\)|previous\.p|[A-Za-z0-9_-]+\.each\(((state|attributes)(\.[^.()]+)+|age\((created_at|updated_at|(state|attributes)(\.[^.()]+)+)\))\))$

Response

A recommendation, an unreachable target, or too few outcomes; status says which. With feature, a FeatureThresholdRecommendation.

Apply threshold with the judgment PATCH: {"escalate": threshold} for a bool judgment, {"fraud": {"value": option, "gte": threshold}} for a choice.

status
any
required
threshold
number
required

The threshold on the value the recommendation is for, one of the curve's points.

Required range: 0 <= x <= 1
precision
number
required

Precision at the threshold, read on outcomes the choice of threshold never saw: the outcomes are split five ways, the threshold is chosen again on four parts and read on the fifth, and the reads are pooled. It is usually a little under the curve's point at the threshold, which is read on every outcome, and can be under the target: it is what to expect on new answers.

Required range: 0 <= x <= 1
recall
number
required

Recall at the threshold, read the same way as precision.

Required range: 0 <= x <= 1
interval
object
required

The 95% interval of the targeted metric at the threshold, on the same read as precision.

outcomes
integer<int64>
required

The number of outcomes the recommendation rests on.

Required range: x >= 100
fitted_on
enum<string>
required

queue when the epoch's labelling-queue labels alone number 100, with 20 of each class: the recommendation then rests on them only, each weighted back to your real traffic, and its interval comes from how many labels each band has and how common the band is. Otherwise all: every outcome, each counting once.

Available options:
all,
queue
from_previous_epoch
boolean
required

True when the current engine epoch has too few outcomes (fewer than 100, or fewer than 20 of either class) and the previous epoch's were used.

curve
object[]
required

Precision and recall at each threshold from 0.00 to 1.00 in steps of 0.01, lowest first: 101 points.

Maximum array length: 101
warnings
object[]
required

The epoch's calibration warnings, as its report carries them (CoverageWarning). A recommendation that rests on labels that leave the live answers uncovered, or that read like the outcome, says so here.

outcomes_by_source
object

The outcomes the recommendation rests on, by where they came from; all queue when fitted_on is queue. A threshold on a feature, and a choice among candidates, leave it out.

acts_on
integer<int64>

A bool's p only. The live answers the threshold would select, as readers read them now (the corrected p on a judgment with features). Absent on a choice, a composite and a choice among candidates.

Required range: x >= 0
covered_by
integer<int64>

A bool's p only. The labels whose p lies at or above the threshold, which is what the precision claimed here rests on.

Required range: x >= 0
held
object | null

A bool's p only. labels_do_not_cover when more than 20% of the live answers it would select have a raw p outside the range the labels cover, so the claimed precision says nothing about much of what the threshold acts on. The threshold is still given, and can be applied. Null when the labels cover what it acts on.