CaMa survival: the SEER interval-survival pipeline as a scenario with population results
models/cama/seer_survival is the SEER survival pipeline as Hamilton dataflows, with the interval LR and network keeping their per-interval fits and surviving an interval without deaths. models/cama/survival is the scenario: it indexes the total cohort at the first invasive biopsy report (steps/indexing.py), derives the covariates and the outcome from the cohort's events, fits the interval survival, writes the five routines and publishes the population curves (analisis/curvas.json) with the version. An estimate may carry the model's own index date.
This commit is contained in:
@@ -6,8 +6,9 @@ anything runs and nothing in the model imports MLflow:
|
||||
|
||||
- `from_.cohort_source(target="cohort", source=...)` and `from_.cohort_source_lineage(target="cohort_lineage",
|
||||
source=...)`: the build's long frame and its lineage, from any `models.io.storage` source (the database or a file).
|
||||
- `to.registered_model(id="registered_model", dependencies=["fitted_model", "metrics", "routines"], ...)`: records
|
||||
each routine (ML-01a, `TrainingRun.log_routine`), logs the fitted model in the open `TrainingRun` (`tracking`),
|
||||
- `to.registered_model(id="registered_model", dependencies=["fitted_model", "metrics", "routines", "population"], ...)`:
|
||||
records each routine (ML-01a, `TrainingRun.log_routine`), the dataflow's `population` as the version's `analisis/`
|
||||
files when it has one (`TrainingRun.log_analysis`), logs the fitted model in the open `TrainingRun` (`tracking`),
|
||||
records the metrics and the config, closes the run, and registers and describes the version (`registry`). Its value
|
||||
is the version's metadata. A dataflow without `routines` still trains and registers, but the registry won't promote
|
||||
it (`ROUTINE_KINDS`).
|
||||
@@ -114,6 +115,8 @@ class RegisteredModelSaver(DataSaver):
|
||||
model, metrics = data["fitted_model"], _numbers(data["metrics"])
|
||||
for kind, record in data.get("routines", {}).items():
|
||||
self.run.log_routine(kind, record)
|
||||
for name, record in data.get("population", {}).items():
|
||||
self.run.log_analysis(name, record)
|
||||
packages = _own_packages(model)
|
||||
for package in packages:
|
||||
cloudpickle.register_pickle_by_value(package)
|
||||
|
||||
@@ -50,6 +50,7 @@ from models.io.storage import ReadOnlyRepository, resolve_repository
|
||||
ARTIFACT_ROOT_ENV = "MLFLOW_ARTIFACT_ROOT"
|
||||
MODEL_PATH = "model"
|
||||
ROUTINES_PATH = "rutinas"
|
||||
ANALYSIS_PATH = "analisis"
|
||||
# The routines §5 of the requirements names; a version is promoted only when its run recorded each one.
|
||||
ROUTINE_KINDS = (ArtifactKind.MUESTREO, ArtifactKind.DATOS_FALTANTES, ArtifactKind.METODO_ANALITICO,
|
||||
ArtifactKind.BALANCE_CLASES, ArtifactKind.CONFIANZA_SALIDA)
|
||||
@@ -191,6 +192,11 @@ class TrainingRun:
|
||||
that too (for instance a class balance of "none"), so the run still says what happened."""
|
||||
self.client.log_text(self.run_id, json.dumps(record, ensure_ascii=False, indent=1, default=str), routine_path(kind))
|
||||
|
||||
def log_analysis(self, name: str, record: dict[str, Any]) -> None:
|
||||
"""What the run found about its cohort, a JSON file `analisis/<name>.json` that the version publishes: the
|
||||
population results a dashboard draws, which are not a prediction of any member."""
|
||||
self.client.log_text(self.run_id, json.dumps(record, ensure_ascii=False, default=str), f"{ANALYSIS_PATH}/{name}.json")
|
||||
|
||||
def log_model(self, model, *, signature=None, requirements: list[str] | None = None) -> str:
|
||||
"""Saves `model` under the run's `model` folder, tags the run with its `modelo_sha` and returns it.
|
||||
Once per run. `signature` describes columns and types only: no input example, so no patient data
|
||||
|
||||
Reference in New Issue
Block a user