cleverly.datasets.make_randomized_pilot#

cleverly.datasets.make_randomized_pilot(n: int = 1000, *, seed: int | Generator | None = None, backend: Literal['pandas', 'polars'] | str | None = None) → tuple[Any, dict[str, float]][source]#

Draw the randomized pilot of the navigation offer, with its recorded offer chances.

Parameters:
nint

Number of discharges.

seedint, Generator, or None

Seed or NumPy random generator.

backend{“pandas”, “polars”, “pyarrow”} or None, default=None

Dataframe backend. None uses pandas when installed, then the first available backend.

Returns:
dataframe

One row per discharge: transition_success (1 or 0), transition_navigation (the offer, 1 or 0), high_risk (1 when discharge_risk is above 0), discharge_risk, prior_utilization, medication_burden, age, and the recorded chances chance_no_offer and chance_offer.

truthdict of str to float

The exact values of randomized_pilot_truth().

See also

cleverly.datasets.randomized_pilot_truth

The exact truth of this law.

cleverly.datasets.navigation_protocol

The protocol of the program these data describe.

Notes

The offer chance is 0.2 in the low-risk group and 0.8 in the high-risk group (PILOT_OFFER_CHANCES). The high-risk group also has a lower success rate, so a plain comparison of offered and other patients is confounded by the risk group. The module docstring gives the law.

Examples

>>> from cleverly.datasets import make_randomized_pilot
>>> frame, truth = make_randomized_pilot(n=500, seed=3)
>>> frame.shape
(500, 9)
>>> sorted(frame.groupby("high_risk")["chance_offer"].first().round(2))
[0.2, 0.8]