A training run takes every model; the public cohorts' code lives with the tests
This commit is contained in:
@@ -21,45 +21,6 @@ RESAMPLES = 200
|
||||
MIN_EVENTS = 15 # a scenario is drawn when it has this many recurrences
|
||||
CAP_MONTHS = 72 # the Weibull curves' extent
|
||||
GRID_POINTS = 289 # 0 to CAP_MONTHS by quarter months
|
||||
LABELS = {"metabric": "METABRIC", "scanb": "SCAN-B", "site": "Sitio"}
|
||||
|
||||
# Each scenario: covariate -> the categories it takes (AND across covariates).
|
||||
SCENARIOS = {
|
||||
"metabric": {
|
||||
"RE+ · sin ganglios · tumor ≤20 mm (bajo riesgo)": {
|
||||
"Receptor_estrogeno": ["Positive"], "Ganglios_positivos": ["0"],
|
||||
"Tamano_tumor": ["<=20 mm"]},
|
||||
"Ganglios 4+": {"Ganglios_positivos": ["4+"]},
|
||||
"Tumor >50 mm": {"Tamano_tumor": [">50 mm"]},
|
||||
"< 45 años": {"Edad": ["<45"]},
|
||||
"≥ 75 años": {"Edad": ["75+"]},
|
||||
"Basal (PAM50)": {"Subtipo_PAM50": ["Basal"]},
|
||||
"HER2 (PAM50)": {"Subtipo_PAM50": ["Her2"]},
|
||||
"Luminal B (PAM50)": {"Subtipo_PAM50": ["LumB"]},
|
||||
"RE+ · 1-3 ganglios · cirugía conservadora": {
|
||||
"Receptor_estrogeno": ["Positive"], "Ganglios_positivos": ["1-3"],
|
||||
"Cirugia": ["BREAST CONSERVING"]},
|
||||
"RE− · grado 3": {"Receptor_estrogeno": ["Negative"], "Grado_histologico": ["3"]},
|
||||
},
|
||||
"scanb": {
|
||||
"Luminal A · sin ganglios · tumor ≤20 mm (bajo riesgo)": {
|
||||
"Subtipo_clinico": ["Luminal A"], "Ganglios_positivos": ["0"],
|
||||
"Tamano_tumor": ["<=20 mm"]},
|
||||
"Ganglios 4+": {"Ganglios_positivos": ["4+"]},
|
||||
"Tumor >50 mm": {"Tamano_tumor": [">50 mm"]},
|
||||
"< 45 años": {"Edad": ["<45"]},
|
||||
"≥ 75 años": {"Edad": ["75+"]},
|
||||
"Basal-like": {"Subtipo_clinico": ["Basal-like"]},
|
||||
"HER2+ (luminal B HER2+ o no luminal)": {
|
||||
"Subtipo_clinico": ["Luminal B HER2+", "Non-luminal HER2+"]},
|
||||
"Luminal B HER2−": {"Subtipo_clinico": ["Luminal B HER2-"]},
|
||||
"Luminal · 1-3 ganglios · lumpectomía": {
|
||||
"Subtipo_clinico": ["Luminal A", "Luminal B HER2-"], "Ganglios_positivos": ["1-3"],
|
||||
"Cirugia": ["Lumpectomy"]},
|
||||
"Grado 3": {"Grado_histologico": ["3"]},
|
||||
},
|
||||
} # fmt: skip
|
||||
SCENARIOS["site"] = SCENARIOS["scanb"] # the site's cohort is described as SCAN-B's
|
||||
|
||||
|
||||
def masks(frame: pd.DataFrame, scenarios: dict) -> dict[str, np.ndarray]:
|
||||
@@ -143,10 +104,10 @@ def _curves(months, event, observed):
|
||||
}
|
||||
|
||||
|
||||
def calculator(fitted: CohortFit, scenarios: dict | None = None) -> tuple[list[dict], list[dict]]:
|
||||
def calculator(fitted: CohortFit) -> tuple[list[dict], list[dict]]:
|
||||
"""The figure record of each scenario with enough recurrences, and its table rows."""
|
||||
source = fitted.cohort.source
|
||||
scenarios = SCENARIOS[source] if scenarios is None else scenarios
|
||||
scenarios = fitted.cohort.scenarios
|
||||
risk = Risk(fitted)
|
||||
found = masks(fitted.cohort.frame, scenarios)
|
||||
rng = np.random.default_rng(SEED) # resamples drawn in order, refitted in parallel
|
||||
@@ -169,7 +130,7 @@ def calculator(fitted: CohortFit, scenarios: dict | None = None) -> tuple[list[d
|
||||
records.append(
|
||||
{
|
||||
"cohorte": source,
|
||||
"cohorte_nombre": LABELS[source],
|
||||
"cohorte_nombre": fitted.cohort.label,
|
||||
"escenario": name,
|
||||
"condiciones": scenarios[name],
|
||||
"n": n,
|
||||
|
||||
Reference in New Issue
Block a user