A training run takes every model; the public cohorts' code lives with the tests

This commit is contained in:
Roberto Treviño
2026-11-29 21:12:17 -06:00
parent 3a749ba8d1
commit a9945bc021
12 changed files with 225 additions and 203 deletions
+4 -9
View File
@@ -41,12 +41,11 @@ class Jobs:
return f"{self.domain}_events"
def routine(self) -> list[str]:
"""The models a train run takes when none is named: all but the slow ones."""
return [n for n, s in self.models.items() if not getattr(s, "slow", False)]
"""The models a train run takes when none is named: all of them."""
return list(self.models)
def scored(self) -> list[str]:
"""The models a score run takes when none is named: all of them (only training is
slow)."""
"""The models a score run takes when none is named: all of them."""
return list(self.models)
def registered(self, name: str) -> str:
@@ -56,9 +55,7 @@ class Jobs:
"""A new registered version of the model, trained on its cohort's timelines up to
`as_of` (default: today), with its metrics and its two generated reports."""
spec, as_of = self.models[name], as_of or date.today()
if spec.cohort is None: # trained on reference data: it writes its own reports
fitted, metrics, found = spec.train(None, as_of)
elif getattr(spec, "reports", False): # trained on its cohort, with its own reports
if getattr(spec, "reports", False): # trained on its cohort, with its own reports
events = gold.timelines(self.events, spec.cohort, as_of)
if events.empty:
raise EmptyCohort(f"{self.registered(name)}: nobody in {spec.cohort}")
@@ -82,8 +79,6 @@ class Jobs:
def score(self, name: str) -> int | None:
"""The champion's risks for today's members of the model's cohort, saved as its risk
batch; None when the model has no champion yet."""
if self.models[name].cohort is None: # scores no patient
return None
found = registry.champion(self.registered(name))
if found is None:
return None