e8c264e571
Every CaCu PIM scenario (cin2_pim, post-colposcopy, post-treatment) and the survival scenario now keep, per
combination of their covariates, the model against its empirical estimate, with the methods each used:
- PIM (models/cacu/cin2_pim/report.py): Turnbull's interval-censored estimate (prevalent = mass at 0, free in (l, r],
unknown baseline in [0, r]; ported from bayes-pim chapter 24) with a bootstrap band, against the mixture refitted on
every coded member with a delta-method band over the likelihood (inverse numerical Hessian, numerical gradient of
CR(t), log scale); E/O at each horizon with log(E/O) taken as normal.
- Survival (models/cacu/survival/report.py): Kaplan-Meier with Greenwood's band against the SEER pipeline's own
subgroup points and bootstrap interval (survival_curves.sv_sub_weights and sv_sub_points, called as they are).
A version keeps the record as analisis/subgrupos.json and a self-contained Plotly page as reportes/subgrupos.html
(TrainingRun.log_report; the saver publishes a dataflow's `reports`). The same drawing is a notebook in the code,
models/cacu/{cin2_pim,survival}/notebooks/reporte_subgrupos.ipynb: chart names and computed results only, a
`parameters` cell, `#| echo: false` cells. models.reports.templates lists those notebooks with the scenarios each serves
and reads one by id, for the WebApi's /governance/notebook-templates. The Jupyter renderer now drops the code of
`#| echo: false` cells, as Quarto does.
plotly>=5.18 joins the `survival-curves` extra (installed by the WebApi) and the dev group.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmQxVJVNR5FYkPAregGEQ7
120 lines
2.8 KiB
Plaintext
120 lines
2.8 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "43f4f2cf",
|
|
"metadata": {
|
|
"tags": [
|
|
"parameters"
|
|
]
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"#| echo: false\n",
|
|
"#| tags: [parameters]\n",
|
|
"report_panels = 24"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "6f01c5ec",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#| echo: false\n",
|
|
"from IPython.display import HTML, Markdown, display\n",
|
|
"from models.cacu.survival import report\n",
|
|
"from models.dags.training import Scenario, dataflow\n",
|
|
"from models.notebook import experiment\n",
|
|
"\n",
|
|
"exp = experiment()\n",
|
|
"scenario = Scenario.load(exp.domain, exp.scenario)\n",
|
|
"found = dataflow(*scenario.modules, config=scenario.config).execute(\n",
|
|
" [\"combination_survival\", \"survival_settings\"], inputs={\"source_cohort\": exp.cohort(), \"cohort_lineage\": exp.lineage()})\n",
|
|
"survival, settings = found[\"combination_survival\"], found[\"survival_settings\"]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "61c183ea",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#| echo: false\n",
|
|
"display(Markdown(\n",
|
|
" f\"**{exp.domain}/{exp.scenario}** · combinaciones: {len(survival)} · pacientes: {sum(r['n'] for r in survival)} · \"\n",
|
|
" f\"defunciones: {sum(r['deaths'] for r in survival)} · horizontes: {', '.join(f'{h} m' for h in settings.horizons)}\"))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "fd940976",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Supervivencia por combinación: Kaplan-Meier y modelo"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "3498c913",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#| echo: false\n",
|
|
"display(HTML(report._figure(survival, scenario.config['etiquetas'], settings, report_panels).to_html(full_html=False, include_plotlyjs=True)))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "2d917e18",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Pacientes y defunciones por combinación"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "1870121a",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#| echo: false\n",
|
|
"display(report._table(survival))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "2ef312c0",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Métodos"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "2c63b624",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#| echo: false\n",
|
|
"display(Markdown(\"\\n\".join(f\"- **{k}**: {v}\" for k, v in report.METHODS.items())))"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|