TEA EEG analysis and age curves, TEA jobs; CaMa recurrence on METABRIC and SCAN-B; reference-data models and routine runs
This commit is contained in:
+15
-5
@@ -36,6 +36,10 @@ class Jobs:
|
||||
def events(self) -> str:
|
||||
return f"{self.domain}_events"
|
||||
|
||||
def routine(self) -> list[str]:
|
||||
"""The models a train or score 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)]
|
||||
|
||||
def registered(self, name: str) -> str:
|
||||
return f"{self.domain}.{name}"
|
||||
|
||||
@@ -43,11 +47,15 @@ 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()
|
||||
fitted, metrics, data = spec.train(gold.timelines(self.events, spec.cohort, as_of), as_of)
|
||||
found = {
|
||||
"technical_validation": self.technical_validation(spec, metrics, data),
|
||||
"interpretability": self.interpretability(spec, fitted, data),
|
||||
}
|
||||
if spec.cohort is None: # trained on reference data: it writes its own reports
|
||||
fitted, metrics, found = spec.train(None, as_of)
|
||||
else:
|
||||
events = gold.timelines(self.events, spec.cohort, as_of)
|
||||
fitted, metrics, data = spec.train(events, as_of)
|
||||
found = {
|
||||
"technical_validation": self.technical_validation(spec, metrics, data),
|
||||
"interpretability": self.interpretability(spec, fitted, data),
|
||||
}
|
||||
# Bootstraps ran on joblib's worker pool: release it now, or the job's process waits
|
||||
# for its idle workers to time out (5 minutes) before it can end.
|
||||
get_reusable_executor().shutdown(wait=True)
|
||||
@@ -58,6 +66,8 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user