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.
This commit is contained in:
2026-11-22 07:47:05 -06:00
parent 03be05fb17
commit a04ceb6301
+2 -9
View File
@@ -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: