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
88 lines
3.7 KiB
TOML
88 lines
3.7 KiB
TOML
domain = "cacu"
|
|
scenario = "survival"
|
|
cohort = "cacu/cohorte_total"
|
|
outcome = "muerte"
|
|
# What a registered version needs to load and predict, pinned to the installed versions when it's logged.
|
|
requirements = ["scikit-learn", "numpy", "pandas", "scipy", "cloudpickle"]
|
|
# The modules whose functions are the graph's nodes, in `with_modules`.
|
|
modules = ["models.cacu.survival.model", "models.cacu.survival.population", "models.cacu.survival.report",
|
|
"models.steps.indexing"]
|
|
description = """
|
|
Prototipo: mortalidad por cualquier causa a 1, 3 y 5 años del diagnóstico de cáncer (provisional: la primera biopsia \
|
|
con carcinoma invasor), a partir de la edad al diagnóstico y de la citología (categorías de KPNC) y el VPH más \
|
|
recientes hasta él. Supervivencia por intervalos del pipeline SEER (regresión logística y red bayesiana combinadas), \
|
|
como la de CaMa. Sin estadio, tratamiento ni validación clínica; la defunción se conoce solo si el hospital la \
|
|
registra."""
|
|
|
|
[config]
|
|
train_fraction = 0.7
|
|
# The model's horizons, in years; `survival.horizons` are the same in months.
|
|
horizons_years = [1.0, 3.0, 5.0]
|
|
# The age at the index in bands, in years. The cytology and HPV are the most recent up to the index, at any distance.
|
|
age_cuts = [35, 45, 55]
|
|
|
|
# The scenario's index and rules, over its source cohort (models/steps/indexing.py). PROVISIONAL: the diagnosis is the
|
|
# first biopsy reported as invasive carcinoma (`CARCINOMA`; in situ is not), which is both the inclusion criterion and
|
|
# the index date; out: no birth date (no age), a death on or before the biopsy. The recruitment window is the source
|
|
# cohort's.
|
|
[config.index]
|
|
kind = "primera_biopsia_invasora"
|
|
event_grades = ["CARCINOMA"]
|
|
# PROVISIONAL (sin_definir): the data are left-truncated; 0 keeps everyone.
|
|
observacion_previa_minima_dias = 0
|
|
|
|
# The SEER pipeline's interval survival (models/cama/seer_survival/survival_models.py), with CaMa's settings but the
|
|
# horizons, the follow-up cap and the HBN's parents.
|
|
[config.survival]
|
|
age_mode = "categorizada"
|
|
include_age = true
|
|
age_cuts = [35, 45, 55]
|
|
hbn_fixed_parents = [] # no expert parents defined for CaCu yet: learned by the BDeu score
|
|
hbn_age_parent = false
|
|
hbn_parents = "fijos" # as the SEER pipeline: the parents learned on the cohort are kept in the bootstrap
|
|
covariates = []
|
|
horizons = [12, 36, 60] # months
|
|
censoring = "riesgo" # a model per interval using all the follow-up
|
|
combine = true # one LR + HBN indicator, per-interval stacking weights
|
|
show_individual = false
|
|
stack_folds = 5
|
|
stack_shrink = 20
|
|
n_boot = 100
|
|
n_boot_sub = 100
|
|
seed = 42
|
|
hbn_ess = 1000
|
|
hbn_max_parents = 5
|
|
k_ident = "clasico"
|
|
curves = "ajustada"
|
|
adjust_step = 3
|
|
show_raw_km = true
|
|
ylim_main = []
|
|
inset_zoom = false
|
|
inset_months = 60
|
|
cap_months = 60 # follow-up is cut here: a later death counts as alive
|
|
min_events_sub = 5
|
|
ks_max_seconds = 120
|
|
ks_sub_max_seconds = 180
|
|
xlim_sub = []
|
|
ylim_sub = {}
|
|
|
|
# What the dashboard's survival chart says (provisional: to be defined with the clinicians).
|
|
[config.etiquetas]
|
|
titulo = "Supervivencia después de la biopsia con carcinoma invasor"
|
|
eje_x = "Meses desde el diagnóstico"
|
|
eje_y = "Supervivencia S(t)"
|
|
km_crudo = "Kaplan-Meier (IC 95 % Greenwood)"
|
|
weibull = "Weibull"
|
|
weibull_fraccional = "Weibull fraccional"
|
|
puntos = "LR + HBN combinado (IC 95 % bootstrap)"
|
|
|
|
# KPNC's index cytology categories, from least to most severe, and the codes of each from the squamous (Bethesda) and
|
|
# the glandular result (as `cin2_pim`); with both results the more severe category wins.
|
|
[config.cytology]
|
|
NILM = ["NORMAL"]
|
|
ASC-US = ["ASC-US"]
|
|
LSIL = ["LIEBG"]
|
|
ASC-H = ["ASC-H"]
|
|
AGC = ["AGC"]
|
|
"HSIL+" = ["LIEAG", "CIS", "ADENOCARCINOMA"]
|