From a04ceb630131464ae093880c4da989807972a7e5 Mon Sep 17 00:00:00 2001 From: edgar Date: Sun, 22 Nov 2026 07:47:05 -0600 Subject: [PATCH] Cycle: score with the models package's `scored_frame`, so a model's risk intervals reach the batch The cycle read the run's horizons and called the model itself; `models.dags.estimation.scored_frame` does both, and also reads whether the run gives each risk's interval. --- webapi/orchestration/estimators.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/webapi/orchestration/estimators.py b/webapi/orchestration/estimators.py index 709d219..473b923 100644 --- a/webapi/orchestration/estimators.py +++ b/webapi/orchestration/estimators.py @@ -38,12 +38,7 @@ class ScenarioEstimator: self._provenance: Provenance | None = None def estimar(self, columnas: list[str], filas: list[tuple]) -> list[tuple]: - import json - - import mlflow.pyfunc - import numpy as np - - from models.dags.estimation import estimate_frame + from models.dags.estimation import scored_frame from models.dags.training import Scenario from models.io.registry import registered_name, registry from models.io.storage import KitBuild @@ -54,13 +49,11 @@ class ScenarioEstimator: build_id = repos.cohort_repository.latest_build(scenario.cohort) resolved = registry.resolve(self.domain, scenario.scenario, self.version) frame = KitBuild(self.domain, build_id).frame() - horizons = json.loads(registry.client.get_run(resolved.run_id).data.params["horizons_years"]) - probabilities = np.asarray(mlflow.pyfunc.load_model(resolved.model_uri).predict(frame)) self.desenlace = scenario.outcome self._provenance = Provenance( modelo_nombre=registered_name(self.domain, scenario.scenario), modelo_version=resolved.version, mlflow_run_id=resolved.run_id, modelo_sha=resolved.modelo_sha) - return [tuple(row) for row in risk_rows(estimate_frame(frame, probabilities, horizons))] + return [tuple(row) for row in risk_rows(scored_frame(resolved, frame))] def procedencia(self) -> Provenance: if self._provenance is None: