T-21g: RiesgoSinteticoCama, el sustituto de CaMa por BI-RADS índice
CSO5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+33
-1
@@ -3,7 +3,15 @@
|
||||
import pytest
|
||||
|
||||
from models import riesgo
|
||||
from models.riesgo import REGLA_SINTETICA_TEA, EstimadorDeRiesgo, Riesgo, RiesgoSintetico, RiesgoSinteticoTea
|
||||
from models.riesgo import (
|
||||
REGLA_SINTETICA_CAMA,
|
||||
REGLA_SINTETICA_TEA,
|
||||
EstimadorDeRiesgo,
|
||||
Riesgo,
|
||||
RiesgoSintetico,
|
||||
RiesgoSinteticoCama,
|
||||
RiesgoSinteticoTea,
|
||||
)
|
||||
|
||||
COLUMNAS = ["pac_id", "fecha_indice", "c", "pap_0", "hpv_0"]
|
||||
FILAS = [(1, "2024-07-01", 0, "NORMAL", "NEGATIVO"), (2, "2024-08-01", 0, "LIEAG", "POSITIVO"), (3, "2024-09-01", 0, None, None)]
|
||||
@@ -71,3 +79,27 @@ def test_la_regla_de_tea_suma_mchat_ucin_y_apgar_bajo():
|
||||
def test_el_sustituto_de_tea_sin_sus_predictores_falla():
|
||||
with pytest.raises(ValueError, match="mchat_0"):
|
||||
RiesgoSinteticoTea().estimar(["pac_id", "fecha_indice"], [])
|
||||
|
||||
|
||||
# --- El sustituto de CaMa (T-21g) --------------------------------------------------------------
|
||||
|
||||
COLUMNAS_CAMA = ["pac_id", "fecha_indice", "d", "t", "birads_0", "calidad_0", "n_ordenes_previas"]
|
||||
|
||||
|
||||
def test_el_sustituto_de_cama_cumple_el_contrato_y_lee_su_cohorte():
|
||||
estimador = RiesgoSinteticoCama()
|
||||
assert isinstance(estimador, EstimadorDeRiesgo)
|
||||
assert estimador.cohorte_url == "cama/cohorte_tamizaje" and estimador.horizontes == (1.0,)
|
||||
|
||||
|
||||
def test_la_regla_de_cama_suma_por_birads_indice_y_4a_cuenta_como_4():
|
||||
filas = [(1, None, None, None, "B2", None, 0), (2, None, None, None, "B4A", None, 0),
|
||||
(3, None, None, None, "B5", None, 0), (4, None, None, None, None, None, 0)]
|
||||
r = REGLA_SINTETICA_CAMA
|
||||
assert [x.probabilidad for x in RiesgoSinteticoCama().estimar(COLUMNAS_CAMA, filas)] == pytest.approx(
|
||||
[r["base"], r["base"] + r["birads_4"], r["base"] + r["birads_5"], r["base"]])
|
||||
|
||||
|
||||
def test_el_sustituto_de_cama_sin_su_predictor_falla():
|
||||
with pytest.raises(ValueError, match="birads_0"):
|
||||
RiesgoSinteticoCama().estimar(["pac_id", "fecha_indice"], [])
|
||||
|
||||
Reference in New Issue
Block a user