cleverly.interventions.ModifiedPolicy#
- class cleverly.interventions.ModifiedPolicy(name: str, pieces: tuple[Piece, ...] | Mapping[object, tuple[Piece, ...]] | None = None, apply: Callable[[...], Any] | None = None, randomizer: Randomizer | None = None, policy_kind: Literal['known', 'estimated'] | None = None)[source]#
A modified treatment policy that the analyst declares.
On a continuous treatment the policy is a tuple of
Pieceobjects, as Assumption 4 of Díaz, Williams, Hoffman and Schenck (2023) requires. The fit checks on the observed doses that the pieces partition the range, that each map is strictly monotone, and that each declared inverse inverts its map. On a categorical treatment the policy isapply(a, h), which maps each unit’s label to a label, and the density ratio is the discrete formula of the same paper. A categorical node whose labels are numbers also takes pieces, applied to the label values.A randomized policy adds a
Randomizerwith finitely many values. Thenpiecesmaps each value to its pieces, orapplytakes a third argument, the value.ModifiedPolicy( "halve above 4", pieces=( Piece(-np.inf, 4.0), Piece(4.0, np.inf, lambda a, h: a / 2, lambda b, h: 2 * b, lambda b, h: 2.0), ), policy_kind="known", )
- Parameters:
- name
str The report label.
- pieces
tupleofPiece,mapping,orNone The pieces, or a mapping from randomizer value to that value’s pieces.
- apply
callable()orNone apply(a, h), orapply(a, h, e)with a randomizer, on a categorical treatment. It returns one label per row.- randomizer
RandomizerorNone The known law of the randomizer.
- policy_kind{“known”, “estimated”}
orNone The declaration that the policy is a known function. A fit accepts
"known"only.
- name
Methods#
Attributes#
- ModifiedPolicy.randomizer: Randomizer | None = None#