# models Python package with the standard `train()`/`predict()` interface for the three screening models — CaCu, CaMa and TEA. Consumed by `WebApi`, but independent of it: this package can read its own training/inference data directly from `Persistance`, without going through `WebApi` at all. ## Structure - `models/base.py` — `ScreeningModel`, the abstract base every model implements (`train(data)` / `predict(data)`). - `models/cacu.py`, `models/cama.py`, `models/tea.py` — one concrete class per domain. ## How entities are accessed from models This package depends on `../Persistance` (a local `uv` path dependency — see `pyproject.toml`), and through it on `../Core`. **As of now this is wiring, not usage**: `train()`/`predict()` in `cacu.py`/`cama.py`/`tea.py` just raise `NotImplementedError` — no model imports `persistance` yet. When real training/inference logic is added, the access pattern is the same repository instances `WebApi` reads from — no separate data layer for `models` to maintain: ```python # models/models/cacu.py from typing import Any from persistance.cacu import citologia_cervical_repository from models.base import ScreeningModel class CaCuModel(ScreeningModel): def train(self, data: Any = None) -> None: if data is None: data = citologia_cervical_repository.list(limit=10_000) # ... fit on `data` def predict(self, data: Any) -> Any: raise NotImplementedError("CaCu prediction is not implemented yet.") ``` The `data: Any = None` default on `train()`/`predict()` is what lets a caller (e.g. `WebApi`) optionally hand over already-fetched rows instead of forcing every call to hit the database — but a model implementation is just as free to call `persistance.` itself when `data` is `None`, exactly like the example above. Each domain's available repositories (`paciente_repository`, `citologia_cervical_repository`, etc.) and how to extend one with table-specific business logic are documented in `../Persistance/README.md`. ## Riesgos (ADR-MD-008) `models/riesgo.py` es el contrato con que Orquestacion pide riesgos a un modelo: `EstimadorDeRiesgo` (recibe el marco ancho de un armado de cohorte y devuelve un `Riesgo` por miembro y horizonte, más su `Procedencia`, las llaves para conciliar con MLflow). `RiesgoSintetico` es un sustituto determinista, sin MLflow, para pruebas y para desplegar sin el modelo real; no es un modelo clínico. El modelo real (Modelo-cacu, con su artefacto de MLflow) entra como otra clase que cumple el contrato (MD-Q6).