CaMa survival figure: Weibull fits on the scenario's own deaths and the pipeline's published points, as its survival stage draws a subgroup
This commit is contained in:
@@ -443,6 +443,25 @@ def test_the_live_figure_scores_a_scenarios_members_with_the_production_model(me
|
||||
assert len(first["km_adjusted"]["S"]) == first["months_max"] + 1 and len(first["weibull_fractional"]["S"]) == len(first["weibull"]["S"])
|
||||
|
||||
|
||||
def test_the_live_figure_fits_its_curves_to_the_members_deaths_and_takes_the_published_points(members_frame, production_model):
|
||||
"""Pins down: the Weibull curves of a scenario's figure follow its members' own deaths (close to their Kaplan-Meier, as the
|
||||
pipeline's survival stage fits a subgroup), and the points are the ones the version published for the subgroup when it did.
|
||||
Fails if the curves are fitted to the model's prediction instead of the data, or the published points are ignored."""
|
||||
from models.cama.survival import live
|
||||
|
||||
rows = [{"modelo": m, "meses": h, "S": 0.8, "IC_inf": 0.7, "IC_sup": 0.9, "subgrupo": "Toda la cohorte"}
|
||||
for m in ("LR", "HBN", "COMB") for h in (6, 12, 18)]
|
||||
published = live.published_points(rows, "Toda la cohorte")
|
||||
|
||||
record = live.curves(SCENARIO, production_model, members_frame, None, published)
|
||||
|
||||
km, weibull = np.asarray(record["km"]["S"]), np.asarray(record["weibull"]["S"])
|
||||
at_months = np.interp(np.arange(len(km)), record["weibull"]["t"], weibull)
|
||||
assert np.abs(at_months - km).max() < 0.05
|
||||
assert record["points"]["COMB"] == {"S": [0.8] * 3, "low": [0.7] * 3, "high": [0.9] * 3}
|
||||
assert live.published_points(rows, "Otro") is None
|
||||
|
||||
|
||||
def test_a_patient_sees_the_scenarios_she_belongs_to_or_the_whole_cohort(members_frame, monkeypatch):
|
||||
"""Pins down: a patient's scenarios are those whose mask holds her and that have enough members to draw; in none, the whole
|
||||
cohort; and a patient outside the cohort is refused. Fails if a scenario too small to draw is offered, or a patient in no
|
||||
|
||||
Reference in New Issue
Block a user