CaMa survival: the scenario points from the pipeline's depuration and survival stage over the current members

This commit is contained in:
Roberto Treviño Cervantes
2026-11-22 23:22:31 -06:00
parent 07c91adbe6
commit 706f7510c5
+15
View File
@@ -118,3 +118,18 @@ def development(labelled_members: pd.DataFrame, desarrollo: dict) -> dict:
def population(population_curves: dict, development: dict) -> dict:
"""Everything the version publishes about its cohort, by file name under `analisis/`: the curves and the development."""
return {**population_curves, **development}
def subgroup_points(labelled_members: pd.DataFrame, desarrollo: dict) -> list[dict]:
"""The pipeline's stages 01 and 05 over the members as they are now: the depuration, then the LR and HBN fitted on them with
each clinical scenario's survival at the horizons and its bootstrap interval (`subgrupos_puntos`), one row per model,
horizon and scenario. What the dashboard draws as a scenario's points between trainings."""
from models.cama.seer_survival import pipeline
with tempfile.TemporaryDirectory() as tmp:
out = Path(tmp)
_recoded_frame(labelled_members).to_csv(out / pipeline.RECODED, index=False)
(out / pipeline.COLUMN_MAP).write_text("{}", encoding="utf-8")
pipeline.run_pipeline(out, only=["01", "05"], everything=True, settings=_seer_settings(desarrollo))
table = pd.read_csv(out / "subgrupos_puntos_LR_HBN.csv").replace([np.inf, -np.inf], np.nan).astype(object)
return table.where(table.notna(), None).to_dict("records")