cleverly.datasets.make_heart_failure#
- cleverly.datasets.make_heart_failure(n: int = 4000, *, seed: int | np.random.Generator | None = None, backend: Backend | str | None = None) tuple[Any, pd.DataFrame][source]#
Patients sent home on a water pill with two parts, followed for readmission and death.
One row per patient, with the columns
older,prior_admissions,dose,dayandevent.eventis 1 for a readmission, 2 for a death and 0 for no event byday. A patient who left follow-up after the day-30 or day-60 check hasevent0 and that day.- Parameters:
- Returns:
dataframeThe observations.
- truth
pandas.DataFrame The exact risks for every pair of the dose whose fluid part a patient gets (
readmission_dose) and the dose whose potassium part they get (death_dose), at each check day, with death counted first within a month: the columnsreadmission_dose,death_dose,day,readmissionanddeath. A row with equal doses is the risk of that dose.
Examples
>>> from cleverly.datasets import make_heart_failure >>> frame, truth = make_heart_failure(n=200, seed=0) >>> list(frame.columns) ['older', 'prior_admissions', 'dose', 'day', 'event'] >>> high = truth.query("readmission_dose == 2 and death_dose == 2 and day == 90") >>> round(float(high["death"].iloc[0]), 4) 0.361