cleverly.datasets.make_treatment_rules#
- cleverly.datasets.make_treatment_rules(n: int = 2000, *, seed: int | Generator | None = None, backend: Literal['pandas', 'polars'] | str | None = None) tuple[Any, dict[str, float]][source]#
Draw the navigation program whose offer helps high-need patients and not low-need ones.
- Parameters:
- Returns:
dataframeOne row per patient, with the columns
need,lives_alone,offerandhome_30.- truth
dictofstrtofloat The share who stay home for 30 days had every patient been offered navigation (
ey_all), had none been (ey_none), and under the best rule (ey_best_rule), each exact; their differenceate(ey_all - ey_none); andbest_rule_cutoff, the need score above which the best rule offers navigation.
See also
cleverly.datasets.treatment_rule_valueThe exact value of any other offer policy.
cleverly.datasets.learned_rule_truthThe true value of the rules a learned-rule fit used.
Examples
>>> from cleverly.datasets import make_treatment_rules >>> frame, truth = make_treatment_rules(n=5, seed=0) >>> list(frame.columns) ['need', 'lives_alone', 'offer', 'home_30'] >>> round(truth["ey_best_rule"] - truth["ey_all"], 4) 0.0434