Survival rates its scenarios' risk factors as Luis's code does; recurrence shares the factor code
This commit is contained in:
@@ -180,3 +180,32 @@ def test_the_models_points_are_the_survival_of_the_cases_it_learned_from(trained
|
||||
original = theirs[(theirs["subgrupo"] == e["escenario"]) & (theirs["modelo"] == "COMB")]
|
||||
gap = np.abs(ours - original.sort_values("meses")["S"].to_numpy()).max()
|
||||
print(f"{e['escenario']}: {TRAIN_FRACTION:.0%} training, gap to the original {gap:.3f}")
|
||||
|
||||
|
||||
# The original's names for the categories both rate alike (stage, grade, receptors).
|
||||
SAME = {
|
||||
("Estadio", "IV"): ("stage", "IV"), ("Estadio", "III"): ("stage", "III"),
|
||||
("Estadio", "II"): ("stage", "II"), ("Estadio", "0 (in situ)"): ("stage", "0"),
|
||||
("Grado_histologico", "G3"): ("grade", "3"), ("Grado_histologico", "G1"): ("grade", "1"),
|
||||
("Receptor_progesterona", "Negativo"): ("pr", "negative"),
|
||||
} # fmt: skip
|
||||
|
||||
|
||||
def test_risk_factors_rate_as_the_originals(trained):
|
||||
"""The risk factors of death by 18 months (models.factors, as `06_factores_riesgo.py`)
|
||||
on the same SEER cases: the same direction for every category both rate, the same class
|
||||
for stage and grade, odds ratios within 20 % and 18-month survival within 0.05. The
|
||||
original also rates the stability of its stepwise selection and reads the Markov blanket
|
||||
of a learned network; the platform's model has neither stepwise selection nor PR among
|
||||
its network's parents, so PR negative is "sugerente" here and "robusto" there."""
|
||||
spec, model, _, data = trained
|
||||
members = pd.concat([data["train"], data["test"]]).reset_index(drop=True)
|
||||
ours = survival.risk_factors(spec, model, members).set_index(["variable", "categoria"])
|
||||
theirs = _original("factores_riesgo.csv").set_index(["variable", "categoria"])
|
||||
for key, mine in SAME.items():
|
||||
a, b = theirs.loc[key], ours.loc[mine]
|
||||
assert b["clasificacion"].split()[0] == a["clasificacion"].split()[0], key
|
||||
if key[0] != "Receptor_progesterona":
|
||||
assert b["clasificacion"] == a["clasificacion"], key
|
||||
assert b["OR_muerte"] == pytest.approx(a["OR_muerte"], rel=0.2), key
|
||||
assert b["S_categoria"] == pytest.approx(a["S18_categoria"], abs=0.05), key
|
||||
|
||||
Reference in New Issue
Block a user