A model whose cohort is empty at a site is skipped, not a failed train run
This commit is contained in:
@@ -14,6 +14,10 @@ from joblib.externals.loky import get_reusable_executor
|
||||
from persistance import gold, registry
|
||||
|
||||
|
||||
class EmptyCohort(ValueError):
|
||||
"""The site has nobody in a model's cohort (no colposcopies, say): nothing to learn from."""
|
||||
|
||||
|
||||
class Predictor(mlflow.pyfunc.PythonModel):
|
||||
"""A fitted model as MLflow serves it: patient timelines in (gold `<domain>_events` rows
|
||||
with each patient's index date), one row per patient and horizon out."""
|
||||
@@ -51,6 +55,8 @@ class Jobs:
|
||||
fitted, metrics, found = spec.train(None, as_of)
|
||||
else:
|
||||
events = gold.timelines(self.events, spec.cohort, as_of)
|
||||
if events.empty:
|
||||
raise EmptyCohort(f"{self.registered(name)}: nobody in {spec.cohort}")
|
||||
fitted, metrics, data = spec.train(events, as_of)
|
||||
found = {
|
||||
"technical_validation": self.technical_validation(spec, metrics, data),
|
||||
|
||||
Reference in New Issue
Block a user