Survival rates its scenarios' risk factors as Luis's code does; recurrence shares the factor code

This commit is contained in:
Roberto Treviño
2026-11-29 12:38:56 -06:00
parent f3f79831bf
commit f369e8f2eb
6 changed files with 335 additions and 174 deletions
+1 -6
View File
@@ -21,6 +21,7 @@ from sklearn.metrics import roc_auc_score
from sklearn.model_selection import train_test_split
from models.cama.recurrence.cohorts import Cohort, at_horizon
from models.factors import variable_of
HORIZONS = (12, 36, 60) # months
SEED = 42
@@ -203,12 +204,6 @@ def c_index(cohort: Cohort) -> float:
return float(concordance_index(test["tiempo_meses"], -risk, test["evento"]))
def variable_of(term: str, covariates: list[str]) -> str:
"""The covariate a dummy belongs to (the longest name it starts with)."""
found = [c for c in covariates if term.startswith(c + "_")]
return max(found, key=len) if found else term
@dataclass
class Horizon:
"""A horizon's cohort size, split fit and bootstrap (AUC pairs, and how often each