cleverly.datasets.treatment_rule_value#

cleverly.datasets.treatment_rule_value(policy: Callable[[pd.DataFrame], Any], *, grid_points: int = 40001) → float[source]#

Return the share who stay home for 30 days, had the offer followed policy.

Parameters:
policycallable()

Takes a frame with the columns need and lives_alone and returns, for each row, the probability of an offer: 0 or 1 for a rule, a value in between for a random offer.

grid_pointsint, default=40001

The points of the trapezoid rule over need, for each value of lives_alone.

Returns:
float

\(\Psi_p\), the value of the policy. A policy that switches between 0 and 1 a few times over need has an error of about 1e-5 at the default grid.

See also

cleverly.datasets.make_treatment_rules

The law, and the exact value of each static plan.

Examples

>>> from cleverly.datasets import treatment_rule_value
>>> round(treatment_rule_value(lambda frame: frame["need"] > -0.1), 4)
0.7197