T-21f: RiesgoSinteticoTea, el sustituto de TEA sobre la cohorte de tamizaje
CSO5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+27
-1
@@ -3,7 +3,7 @@
|
||||
import pytest
|
||||
|
||||
from models import riesgo
|
||||
from models.riesgo import EstimadorDeRiesgo, Riesgo, RiesgoSintetico
|
||||
from models.riesgo import REGLA_SINTETICA_TEA, EstimadorDeRiesgo, Riesgo, RiesgoSintetico, 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)]
|
||||
@@ -45,3 +45,29 @@ def test_la_procedencia_trae_las_cuatro_llaves_y_su_sha_cambia_con_la_regla(monk
|
||||
def test_sin_los_predictores_falla_y_los_nombra():
|
||||
with pytest.raises(ValueError, match="pap_0"):
|
||||
RiesgoSintetico().estimar(["pac_id", "hpv_0"], [(1, None)])
|
||||
|
||||
|
||||
# --- El sustituto de TEA (T-21f) ---------------------------------------------------------------
|
||||
|
||||
COLUMNAS_TEA = ["pac_id", "fecha_indice", "d", "t", "mchat_0", "apgar_5min", "ingreso_ucin", "n_antecedentes",
|
||||
"hipoacusia_0"]
|
||||
|
||||
|
||||
def test_el_sustituto_de_tea_cumple_el_contrato_y_lee_su_cohorte():
|
||||
estimador = RiesgoSinteticoTea()
|
||||
assert isinstance(estimador, EstimadorDeRiesgo)
|
||||
assert estimador.cohorte_url == "tea/cohorte_tamizaje" and estimador.horizontes == (2.0,)
|
||||
|
||||
|
||||
def test_la_regla_de_tea_suma_mchat_ucin_y_apgar_bajo():
|
||||
filas = [(1, None, None, None, "RIESGO_BAJO", 9.0, 0.0, 0, None),
|
||||
(2, None, None, None, "RIESGO_ALTO", 6.0, 1.0, 2, "LEVE"),
|
||||
(3, None, None, None, None, None, None, 0, None)]
|
||||
r = REGLA_SINTETICA_TEA
|
||||
assert [x.probabilidad for x in RiesgoSinteticoTea().estimar(COLUMNAS_TEA, filas)] == pytest.approx(
|
||||
[r["base"], r["base"] + r["mchat_alto"] + r["ucin"] + r["apgar_bajo"], r["base"]])
|
||||
|
||||
|
||||
def test_el_sustituto_de_tea_sin_sus_predictores_falla():
|
||||
with pytest.raises(ValueError, match="mchat_0"):
|
||||
RiesgoSinteticoTea().estimar(["pac_id", "fecha_indice"], [])
|
||||
|
||||
Reference in New Issue
Block a user