Skip to content
Increment 0.1.0a6 prerelease documentation. These docs describe the increment 0.1.0a6 prerelease (v0.1.0a6). Its API may change. Install: pip install 'increment==0.1.0a6' Keep any extras requested by the guide, such as increment[dashboard]==0.1.0a6.

Logged-policy evaluation

Off-policy contrast compares two registered policies using a decision trace logged under one fixed policy version. It uses LoggedTrace.from_records or from_frame, not an experiment builder. See the guide for the estimand, assumptions, and floors. Each constructor requires exactly one logging-law route: registry=, complete record-level logging_distributions=, or frame logging_distribution_column=. The estimator and admission bounds are the same for either route.

estimate_policy_contrast(trace, target, reference, alpha)

Estimate Delta_T(target, reference) from an admitted trace.

Gates run in order: alpha; one fixed logging law for the whole trace; policy support at every logged history; the independent-unit inference floor; the effective-sample-size floor at every decision index for both policies; a finite positive t critical value; a float64 representation of every reported statistic. Each refusal is a coded error whose context carries the diagnostics computed so far.

LoggedTrace

Admitted, ordered, complete-horizon decision records.

Construct with :meth:from_records or :meth:from_frame, which admit either a registered logging policy or a complete recorded distribution. The model validator re-checks every structural admission rule, so a trace instance is always ordered by (unit_id, decision_index), has exactly horizon closed rewards per unit, one fixed candidate set, and one admitted logging distribution per record.

PolicyRegistry(policies)

Immutable lookup of registered policies by (policy_id, version).

TabularPolicy

A policy whose action distribution is a table over one context value.

probabilities maps the value of context[context_key] to an action distribution; default applies when the key is absent or its value is not tabulated. A policy with an empty table and a default ignores the history entirely (the spec’s reference-policy).

Persistence: Python-mode dumps, copy.deepcopy and (trusted) pickle keep every key type and rebuild an equivalent policy. JSON dumps roundtrip only when every table key is a string; any other key type refuses at serialization with logged_policy.policy.json_context_key rather than becoming a different key. An absent default stays absent.

PolicyValueContrast

Fixed-horizon contrast Delta_T = V_T(target) - V_T(reference) on the reward scale.

ess_by_time is the smaller of the two policies’ effective sample sizes at each decision index and max_weight_by_time the larger of their maximum cumulative weights; the per-policy tuples carry both. The interval is a two-sided Wald interval from the unit-clustered sandwich standard error with a t reference on n_units - 1 degrees of freedom.