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:
- policy
callable() Takes a frame with the columns
needandlives_aloneand returns, for each row, the probability of an offer: 0 or 1 for a rule, a value in between for a random offer.- grid_points
int, default=40001 The points of the trapezoid rule over
need, for each value oflives_alone.
- policy
- Returns:
float\(\Psi_p\), the value of the policy. A policy that switches between 0 and 1 a few times over
needhas an error of about1e-5at the default grid.
See also
cleverly.datasets.make_treatment_rulesThe 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