cleverly.datasets.make_population_impact#

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

Draw the population-impact program data and return the exact truths.

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: top_box (1 for a top-box transition, missing where the survey did not come back), transition_navigation (1 for the offer), the three standardized baseline covariates, pcp_visit_7d (1 for a primary-care visit within 7 days) and responded (1 where the survey came back).

truthdict of str to float

The population truths of population_impact_truth().

See also

cleverly.datasets.population_impact_truth

The truths, without a draw.

cleverly.datasets.navigation_protocol

The program protocol a tutorial derives its own from.

Examples

>>> from cleverly.datasets import make_population_impact
>>> frame, truth = make_population_impact(n=500, seed=3)
>>> print(*frame.columns, sep="\n")
top_box
transition_navigation
discharge_risk
age
prior_utilization
pcp_visit_7d
responded
>>> bool(frame["top_box"].isna().equals(frame["responded"] == 0))
True