Commit Graph

131 Commits

Author SHA1 Message Date
ulises 74bec6d0eb Submodule URLs relative to this repository's remote 2026-11-23 20:01:47 -06:00
ulises 2a04ee8c8e TEA EEG: training and analysis choose the cluster, EEG ids are text, run progress snapshots; tea library pointer 2026-11-23 09:29:41 -06:00
Roberto Treviño Cervantes f9d97f4d12 Scenarios: batch_estimates turns off the cycle's per-member scoring; off for CaMa recurrence, answered per clinical scenario 2026-11-23 00:14:14 -06:00
Roberto Treviño Cervantes 674bdc4bb2 CaMa survival figure: every point from the pipeline's survival stage, the whole cohort's included 2026-11-22 23:46:57 -06:00
Roberto Treviño Cervantes 678c02b79d Merge dev into the CaMa consolidation branch 2026-11-22 23:27:34 -06:00
edgar 1c445286eb Merge pull request 'CaCu models: survival interval, yearly PIM horizons, registry listing of production scenarios' (#14) from integration/cacu-indicadores into dev
Reviewed-on: http://10.0.10.41:3000/ISSSTELEON/models/pulls/14
2026-11-22 23:24:57 -06:00
Roberto Treviño Cervantes 706f7510c5 CaMa survival: the scenario points from the pipeline's depuration and survival stage over the current members 2026-11-22 23:22:31 -06:00
Roberto Treviño Cervantes 07c91adbe6 CaMa survival figure: Weibull fits on the scenario's own deaths and the pipeline's published points, as its survival stage draws a subgroup 2026-11-22 22:59:47 -06:00
alberto 8545c36bc4 Merge pull request 'TEA: ADOS-2 scoring command and library pointer' (#13) from feature/tea-eeg-analysis into dev
Reviewed-on: http://10.0.10.41:3000/ISSSTELEON/models/pulls/13
2026-11-22 22:13:32 -06:00
ulises 6d653e9f17 TEA: score ADOS-2 evaluations from their items (calibrated severity score and classification) with a score-ados2 command; tea library pointer 2026-11-22 22:01:50 -06:00
ulises a9ab8612f8 TEA: ADOS-2 association job, EEG zone values, spike minutes as exposure and the count baselines' reference range; tea library 0.3.0 2026-11-22 21:47:15 -06:00
edgar ccaa6fca12 Registry: list a domain's scenarios with a version in production 2026-11-22 20:34:38 -06:00
edgar e1f388c702 Read the CaCu PIM curves at every year from 0 to 5
The horizons are evaluation points of the fitted I-spline curve, so the fit is unchanged; each batch gains the 2- and 4-year rows.
2026-11-22 20:26:47 -06:00
edgar 55d675c8a8 CaCu survival: each risk comes with its combination's bootstrap interval
The covariates are categorical, so every member of a combination gets the same mortality. Training keeps, per
combination of its members, the percentiles of the mortality of `risk_interval_replicas` refits on bootstrap resamples
(`risk_interval_level`, 0.95), and estimating writes it as each risk's interval. A combination training never saw has
none.
2026-11-22 20:10:40 -06:00
Roberto Treviño Cervantes b3e02f0980 CaMa recurrence trains on the loaded METABRIC and SCAN-B patients in the total cohort, not on bundled files; the second survival scenario is retired 2026-11-22 19:51:20 -06:00
edgar c676dde0d0 CaCu survival: a case is a carcinoma, invasive or in situ
The scenario's diagnosis is the first biopsy reported as CIS or invasive carcinoma (`event_grades`), so in situ cases
are followed too and a CIS before an invasive carcinoma is the index date.
2026-11-22 19:16:05 -06:00
Roberto Treviño Cervantes 5a10be44d0 CaMa survival: no member is followed past today 2026-11-22 18:04:57 -06:00
edgar 34b26d8c85 CaCu survival: an estimand that shows the probability of surviving
The model gives the probability of dying (`muerte`, like every batch the probability of its outcome); `complement =
"supervivencia"` tells the screens to show its complement as the probability of surviving, from the first invasive
biopsy, with its covariates.
2026-11-22 15:04:03 -06:00
edgar f00dd31450 CaCu PIM estimands: a probability, its covariates, and the surveillance index in short
The quantity is "Probabilidad"; each scenario names the covariates it uses, which the patient's record writes under
the table; the surveillance and cancer scenarios name their index as the latest cytology with cytology and HPV
results.
2026-11-22 15:04:03 -06:00
edgar 547ceedea3 Merge pull request 'CaCu PIM: risk intervals, estimand, latest-cytology index, cancer outcome; pipeline drawings' (#12) from integration/cacu-indicadores into dev
Reviewed-on: http://10.0.10.41:3000/ISSSTELEON/models/pulls/12
2026-11-22 13:46:19 -06:00
Roberto Treviño Cervantes d91ac7c14b CaMa survival: the members' stage, surgery and adjuvant treatments, read by the clinical scenarios and the development stages 2026-11-22 11:36:52 -06:00
edgar 28858c6966 CaCu: the surveillance PIM with cancer as the outcome (cancer_pim)
The same dataflow, cohort, index and prediction index as the CIN2+ surveillance model, with carcinoma as the only
event, like the cancer column of KPNC's tables: the patient's two risks are of the same visit. The subgroup report
template serves it too.
2026-11-22 09:34:35 -06:00
edgar 835817930d CaCu PIM: the estimand says what the number is, not how its interval is computed
The interval's method (delta method on the log scale) is the version's subgroup report's; the screens that show the
estimand don't need it.
2026-11-22 09:34:35 -06:00
Roberto Treviño Cervantes 94c7cf93dc Merge the CaMa SEER survival and METABRIC/SCAN-B recurrence work into dev's CaMa models 2026-11-22 09:18:15 -06:00
ulises 73c5176482 CaMa recurrence: the METABRIC and SCAN-B analysis as a model over the loaded cohorts
Luis's recurrence scripts are kept as experiments. `models/cama/recurrence` holds the variable dictionary, the
scenarios and the settings as data (`model.toml`), the writer of each cohort file as CaMa import files, the recode of the
timeline into the per-patient frame and the analysis (Cramér's-V pruning, logistic terms and Bayesian-network parents per
horizon, the scenario figures). The variable reader of the survival model is public so both share it. Includes the survival
pipeline work this builds on.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-22 08:46:39 -06:00
edgar 7928b478f9 CaCu PIM subgroup report: risks in percent, one scale per panel, the empirical method in plain words
The figure drew proportions with no unit, which read as a risk a hundred times smaller than the table's and the
patient's. Each panel now has its own y scale, so a low-risk combination isn't flattened by a high-risk one, and the
methods describe Turnbull's curve by what each patient contributes to it.
2026-11-22 07:38:47 -06:00
edgar 46bc6bcf39 CaCu PIM: risk intervals, what the number is, and the surveillance risk from the latest cytology
- The registered mixture gives each risk's interval at `risk_interval_level` (delta method on the log scale, from
  the fit's inverse Hessian), so the patient's risk carries it.
- `[estimand]` in `model.toml` says what the model's number is (quantity, outcome, index date, unit of the horizons,
  interval), read into `Scenario.estimand` for the screens that show it.
- The surveillance scenario predicts from each patient's latest cytology with both cytology and HPV results, before
  any colposcopy (`prediction_index = "ultima_citologia"`): every new complete sample is a new index date, and a
  sample still missing a result gives way to the one before. Patients past a colposcopy are the post-colposcopy
  scenario's. Training keeps the first cytology in the window. The rule runs inside the registered model, so it loads
  without this repository.
2026-11-22 07:38:39 -06:00
edgar 78a4748592 Estimates: each risk's interval when the model gives one; a member it can't place has no rows
A run with `risk_interval_level` has a model that gives, after the risk at each horizon, its interval's lower and
upper ends; the estimate keeps them as `ic_bajo` and `ic_alto`, the contract checks that they hold the risk, and the
batch stores them. `scored_frame` is the one place that reads the run and calls the model, for the command and the
WebApi's cycle. A member whose risk is NaN (a combination the model never saw) is left out instead of stopping the
whole batch.
2026-11-22 07:38:17 -06:00
edgar 271c799d0a Tests: the PIM likelihood gives KPNC's published risks to machine precision
A fixture of the published cumulative risks at 0-5 years of KPNC's tables 1, 17, 18, 24 and 25 (CIN2+ and CIN3+),
with the knots, spline coefficients and proportional factors that reproduce them, checked against
`cumulative_risk` to 1e-12. Aggregates of public tables only.
2026-11-22 07:38:07 -06:00
edgar d090bb0f9f Governance: each version stores the drawing of its dataflow as files of its own
Training stores the scenario's Hamilton graph as `diagramas/pipeline.dot` and, when Graphviz's `dot` is installed,
`diagramas/pipeline.svg`, listed next to the version's other files. Without the `graphviz` package there is no
drawing and training goes on.
2026-11-22 07:38:07 -06:00
luis 9c7c718a7b Tests for the SEER survival pipeline's stages and runner 2026-11-22 03:28:04 -06:00
luis 42161eb612 CaMa SEER survival pipeline: the six scripts as Hamilton DAGs, one module of nodes per stage and the heavy routines apart
Stages 01-06 (depuration, MCA balancing and categorization, bootstrap indices, stepwise LR and hybrid Bayesian network, survival curves, risk factors), settings in model.toml, run.py writing each stage's files and pipeline.py as the runner that replaces ejecutar_pipeline.py. New extras seer-survival and seer-survival-dca; experiments/ excluded from the wheel.
2026-11-22 03:28:04 -06:00
luis c70aef2a04 Keep the original SEER survival scripts as experiments (not packaged) 2026-11-22 03:28:01 -06:00
edgar 0b25a5687e Merge pull request 'CaCu survival: all-cause mortality at 1, 3 and 5 years and subgroup reports' (#10) from integration/cacu-indicadores into dev
Reviewed-on: http://10.0.10.41:3000/ISSSTELEON/models/pulls/10
2026-11-22 01:00:39 -06:00
edgar e8c264e571 Subgroup reports for CaCu's survival and PIM scenarios, as version files and as notebooks in the code
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
2026-11-21 22:41:04 -06:00
edgar 9cba11c2ec CaCu survival: all-cause mortality at 1, 3 and 5 years from the cancer diagnosis
A new scenario, models/cacu/survival, from the total cohort. PROVISIONAL index: the first biopsy reported as invasive
carcinoma (`primera_biopsia_invasora` with `CARCINOMA`), both the inclusion criterion and the index date; out without
a birth date or with a death on or before it. The covariates are the most recent observations up to the diagnosis:
the age group at it, the latest cytology sample in KPNC's categories and the latest HPV result. The outcome is the
timeline's `defuncion` (emitted by the monorepo's CaCu timeline on its own branch).

The fit is the SEER pipeline's interval survival as cama/survival runs it (LR and Bayesian network per interval,
stacked), and a version publishes the same population record, `analisis/curvas.json` (KM with Greenwood, adjusted KM,
Weibull, LR/HBN/combined points with bootstrap intervals): the survival panel a collaborator's proof of concept asked
for, without its synthetic covariates or its fixed 50:50 mix.

CaMa's code is not changed. The nodes that don't depend on the covariates call CaMa's; encode, interval_cohort,
IntervalSurvival, labelled_members, missing_data, analytic_method and survival_frame are copies over CaCu's covariates,
because CaMa's read its FEATURES as a module constant. Issue #9 records the duplication and how to remove it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmQxVJVNR5FYkPAregGEQ7
2026-11-21 21:37:43 -06:00
edgar feb934da2f ML-01a: the training run is the registered routine; its routine records are reported, not required
Not every model has each of the five routine records (a prevalence-incidence mixture has no class balance or
classifier calibration), so requiring all of them blocked promotion of models whose run is in order. The check now
passes when the version comes from its training run and its detail says which records the run holds
("registros de rutina: k de 5 (...)"). A version declared over the API still can't be promoted: it has no saved
model (ML-01b).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HmQxVJVNR5FYkPAregGEQ7
2026-11-21 19:17:45 -06:00
angel b608dc0b53 Merge pull request 'CaMa: survival and recurrence models, the live scenario figures, and their training from governance' (#7) from feature/cama-roundtrip into dev
Reviewed-on: http://10.0.10.41:3000/ISSSTELEON/models/pulls/7
2026-11-21 15:03:33 -06:00
rockdrigo 1b9afb22ea CaMa: the SEER stages see the molecular subtype; the subtype derivation is shared; the live menu reads the scenarios that can be drawn 2026-11-21 14:43:46 -06:00
rockdrigo 3fdc59df6d CaMa recurrence: the CLI entry imports its data folder; test of the entry a governance job runs 2026-11-21 13:43:19 -06:00
rockdrigo 9fe1f86c8b CaMa recurrence: a version trains, registers and publishes its figures (test) 2026-11-21 13:41:15 -06:00
rockdrigo 0804937578 CaMa recurrence: the METABRIC and SCAN-B analysis as a trainable scenario, with its scenario figures and a patient-to-scenario match 2026-11-21 13:34:56 -06:00
rockdrigo e99eb499d6 CaMa survival: the live figure is the clinical scenario's, over the production model and the live cohort 2026-11-21 13:14:06 -06:00
rockdrigo b1006a97d7 CaMa survival: the clinical scenarios are a shared module and stage 6 lists each scenario's risk factors; the live figure drops the unused options 2026-11-21 13:03:19 -06:00
rockdrigo 997aebd068 CaMa survival: a saved model is rehydrated with the current class before scoring 2026-11-21 12:15:22 -06:00
rockdrigo b8936522be CaMa survival: the figure for a selection of members, scored with the production model over the live cohort; the pipeline's chart wording 2026-11-21 12:07:21 -06:00
rockdrigo ec430c3ee3 CaMa survival: the published figure runs the SEER pipeline's stage-5 functions, and the production model keeps its structure settings 2026-11-21 10:33:48 -06:00
rockdrigo 0cf3e60341 CaMa survival: the published figure carries no test-data note 2026-11-21 10:13:47 -06:00
rockdrigo 4c8b559557 CaMa development record: tables carry their column order 2026-11-21 05:03:52 -06:00
rockdrigo f3be09467f CaMa survival: the SEER pipeline is imported only when a run develops the model 2026-11-21 03:33:44 -06:00