Skip to content

ump_spec.models.calibration

module ump-spec

Calibration record (spec §10): routes R1 to R6, checks 0 to 6, PSIS diagnostics.

class

class PsisDiagnostics(StrictModel)

Fields

NameTypeDefaultDescription
khatfloat
essfloat
n_drawsint
r_efffloat | NoneNoneRelative MCMC efficiency of the draws (spec §10); the ESS checked is ess x r_eff. Absent means 1.0.
khat_thresholdProposed | NoneNone
ess_floorProposedProposed(value=400, source='§10')
passedbool | NoneNone
Methods and properties (1)

evaluate method

def evaluate(self) -> PsisDiagnostics

Source: packages/ump-spec/src/ump_spec/models/calibration.py, line 48

class

class CalibrationCheck(StrictModel)

Fields

NameTypeDefaultDescription
indexint
substr | NoneNoneSub-check letter, e.g. ‘a’ for check 2a measurement mapping (§10).
namestr
outcomeCheckOutcome
gatestr | NoneNone
detailstr''

Source: packages/ump-spec/src/ump_spec/models/calibration.py, line 67

class

class Excision(StrictModel)

Fields

NameTypeDefaultDescription
modeExcisionMode'default_applied'not_needed: the flight plus its adstock tail sits outside the training window, so there is nothing to excise (G-CAL-02 passes).
startstr | NoneNone
end_plus_tailstr | NoneNone
tail_weeksint | NoneNone

Source: packages/ump-spec/src/ump_spec/models/calibration.py, line 78

class

class Conflict(StrictModel)

Fields

NameTypeDefaultDescription
zfloat | NoneNone
pfloat | NoneNone
bh_flagboolFalse
qProposedProposed(value=0.1, source='§10')
single_test_flagboolFalse
procedureLiteral['abs_z', 'benjamini_hochberg', 'benjamini_yekutieli'] | NoneNoneSpec §10: the procedure used (|z| rule for m = 1, BH or declared BY).
mint | NoneNoneNumber of tests in this calibration artifact.

Source: packages/ump-spec/src/ump_spec/models/calibration.py, line 88

class

class Calibration(ArtifactDoc)

Fields

NameTypeDefaultDescription
client_idstr | NoneNone
metric_familystr | NoneNoneLegacy top-level metric family (sales_return, brand_awareness, …); the estimand’s own metric_family is preferred. Read by G-EXP-05 (gates._calibration_target) and experiments calibrate.py.
model_id_instr
model_id_outstr | NoneNone
test_result_idslist[str]list()
excluded_test_idslist[str]list()
channelstr | NoneNone
routeRoute
route_attemptedlist[Route]list()
checkslist[CalibrationCheck]list()
excisionExcisionExcision()
conflictConflictConflict()
psisPsisDiagnostics | NoneNone
priorShownNumber | NoneNone
posteriorShownNumber | NoneNone
statusLiteral['committed', 'provisional']'provisional'
approximateboolFalse
refit_queuedboolFalse
fallbackslist[FallbackEntry]list()
tested_channelstr | NoneNoneChannel the tests measured. R6 attach-only docs keep channel null and put the channel here, so maturity does not count them as calibrated.
attach_onlyboolFalseR6: readouts attached beside the model, model unchanged.
model_tierstr | NoneNoneTier (A/B/C/D/X) of model_id_in at calibration time.
granularity_mappingdict[str, Any] | NoneNoneCheck 3 (G-CAL-03): test grain to model grain, weights, split assumption.
prior_for_refitdict[str, Any] | NoneNoneR1/R3: prior handed to the next refit, e.g. {mean, sd, scale, from}.
testslist[dict[str, Any]]list()Per-test working: id, channel, class, tau, se, z, p, flag, discounts.
excluded_reasonstr | NoneNoneWhy tests or the calibration were excluded.
modestr | NoneNoneGate mode the calibration ran under. Written by experiments (calibrate.py).
route_statusstr | NoneNoneStatus of the route in words. Written by experiments (calibrate.py).
pilotbool | NoneNoneTrue for a pilot calibration. Written by experiments (calibrate.py).
commit_eligiblebool | NoneNoneTrue when the calibrated model may be committed. Written by experiments (calibrate.py).
excision_overlapbool | NoneNoneTrue when the excision window overlaps the training window. Written by experiments (calibrate.py).
measurement_mapping_validbool | NoneNoneTrue when the test’s measurement maps onto the model’s KPI. Written by experiments (calibrate.py).
refit_queued_plannedbool | NoneNoneWhether a refit was planned at submission. Written by experiments (calibrate.py).
training_windowdict[str, Any] | NoneNoneModel training window {start, end}. Written by experiments (calibrate.py).
estimand_alignmentdict[str, Any] | NoneNoneHow test and model estimands were aligned (G-EST-02). Written by experiments (calibrate.py).
target_estimanddict[str, Any] | NoneNoneEstimand the calibration targets, e.g. a brand metric family. Written by experiments (calibrate.py).
robust_mixturedict[str, Any] | NoneNoneRobust mixture prior: experiment weight and the vague component (proposed widths). Written by experiments (calibrate.py).
curve_adjustmentdict[str, Any] | NoneNoneCurve rescale applied near current spend. Written by experiments (calibrate.py).
assumptionslist[Any] | NoneNoneAssumed values, each labelled. Written by experiments (calibrate.py).
noteslist[dict[str, Any] | str] | NoneNoneNotes (code, severity, gate, message). Written by experiments (calibrate.py).
Methods and properties (1)

counts_as_calibrated property

counts_as_calibrated: bool

Spec §10: R6 attaches readouts without changing the model, so it never counts as calibrated.

Source: packages/ump-spec/src/ump_spec/models/calibration.py, line 101

function

def psis_khat_threshold(n_draws: int) -> float

§10 (proposed): k-hat < min(1 - 1/log10(S), 0.7).

Source: packages/ump-spec/src/ump_spec/models/calibration.py, line 41

NameTypeValueDescription
RouteLiteral['R1', 'R2', 'R3', 'R4', 'R5', 'R6']
CheckOutcomeLiteral['pass', 'fallback', 'route', 'exclude_and_continue', 'warn', 'skipped']
ExcisionModeLiteral['excise', 'joint_model', 'default_applied', 'not_needed']
ROUTESdict[str, dict[str, Any]]{'R1': {'name': 'prior', 'needs_tiers': ['A'], 'status': 'Supported'}, 'R2': ...
CALIBRATION_CHECKStuple[str, ...]('double_counting_excision', 'estimand', 'admissibility', 'granularity', 'con...
CHECK_GATESdict[int, str | None]{0: 'G-CAL-02', 1: 'G-EST-02', 2: 'G-EXP-05', 3: 'G-CAL-03', 4: 'G-CAL-01', 5...