cleverly.interventions.JointPolicy#
- class cleverly.interventions.JointPolicy(name: str, components: Mapping[Any, Any], randomizer: Randomizer | None = None, policy_kind: Literal['known', 'estimated'] | None = None, order: tuple[str, ...] | None = None)[source]#
A modified treatment policy on a vector node, declared one component at a time.
Díaz, Williams, Hoffman and Schenck (2023, Section 2) let the treatment of a node be a vector \(A_t = (C_t, D_t)\), with categorical components \(C_t\) and continuous components \(D_t\). A joint policy maps each component. A component left out of
componentskeeps its natural value.JointPolicy( "flag everyone, raise the dose of the flagged", components={ "flag": ModifiedPolicy("flag", apply=flag_everyone, policy_kind="known"), "dose": ModifiedPolicy("up if flagged", pieces=(...), policy_kind="known"), }, policy_kind="known", )
The rules below make the density ratio exist, and the fit checks them before any learner (their Assumption 4, applied on each categorical cell and each value of the earlier doses):
component
policy and what its frame
hholdscontinuous
Shift,Scale,Piecewise, or aModifiedPolicywithpieces.hholds the policy frame, the natural values of the node’s categorical components, and the natural values of the doses before it inorder, by component namecategorical
a
ModifiedPolicywithapply, an arithmetic policy on numeric labels, or aRiskRatioTilton a component coded 0 and 1.hholds the policy frame and the natural values of every other component of the nodeA read of any other component of the node raises
DataError,h.get(...)included. With these rules the map of the doses is triangular for each categorical cell, so its Jacobian determinant is the product of the declared derivatives. A dose map that reads a later dose is refused with theorderthat makes it triangular. Maps that read each other in a cycle are refused: a joint map that is not triangular has no checkable declaration here, because a determinant checked on a grid does not establish that the map is one-to-one. ARandomizermay be declared here, on the joint policy, or on a component’sModifiedPolicy. ARiskRatioTiltmay set a binary component coded 0 and 1, as it sets a binary treatment. The randomizers are independent, so the fit reads the policy as one joint randomizer over the product of their values, with product probabilities (joint_branches()).- Parameters:
- name
str The report label.
- components
mapping The component column of the node mapped to that component’s policy. With a randomizer, a mapping from each randomizer value to such a mapping.
- randomizer
RandomizerorNone The known law of the randomizer, or
Nonefor a deterministic policy.- policy_kind{“known”, “estimated”}
orNone The declaration that the policy is a known function. A fit accepts
"known"only.- order
tupleofstrorNone The order of the doses: the map of each dose reads the natural values of the doses before it. It lists every continuous component of the node. A categorical component may be listed and its position has no effect, since a categorical map reads every natural value.
Nonetakes the node’s column order.
- name
Methods#
Attributes#
- JointPolicy.randomizer: Randomizer | None = None#