Guardar variables usadas en cada predicción
This commit is contained in:
@@ -112,6 +112,7 @@ def test_survival_matches_the_current_model_and_publishes_patient_scenarios(monk
|
||||
"stack_w_lr_36m", "stack_w_lr_60m"): # fmt: skip
|
||||
assert metrics[name] == pytest.approx(current["metrics"][name], rel=RTOL), name
|
||||
found = spec.predict(model, events)
|
||||
assert all(set(json.loads(value)) == set(spec.features) for value in found['input_values'])
|
||||
reference = pd.read_parquet(REFERENCE / "ref" / "survival.parquet")
|
||||
both = found.merge(reference, left_on=["person_id", "horizon_years"],
|
||||
right_on=["pac_id", "horizonte_anios"], validate="1:1") # fmt: skip
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import json
|
||||
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from models.cacu.specs import _rows
|
||||
|
||||
|
||||
def test_each_scored_horizon_keeps_the_inputs_of_its_patient():
|
||||
members = pd.DataFrame([
|
||||
{"person_id": "a", "index_date": "2026-01-01", "cytology": "NILM", "hpv": 0},
|
||||
{"person_id": "b", "index_date": "2026-02-01", "cytology": "HSIL", "hpv": 1},
|
||||
])
|
||||
result = _rows(members, np.array([[0.1, 0.2], [0.3, 0.4]]), (0, 5),
|
||||
("cytology", "hpv"))
|
||||
assert [json.loads(v) for v in result.input_values] == [
|
||||
{"cytology": "NILM", "hpv": 0}, {"cytology": "NILM", "hpv": 0},
|
||||
{"cytology": "HSIL", "hpv": 1}, {"cytology": "HSIL", "hpv": 1}]
|
||||
Reference in New Issue
Block a user