Skip to content

v2.1.0

Choose a tag to compare

@DiogoRibeiro7 DiogoRibeiro7 released this 24 Aug 16:51
· 115 commits to develop since this release
fd1ab2f

A twelfth model, the ground truth behind every dataset, a baseline hazard abstraction, two sampler corrections, and documentation rebuilt from scratch.

Reproducibility

Two generators produce different data for the same seed than in 2.0.1, because both were producing wrong data:

  • piecewise_exponential, with two or more breakpoints
  • tdcm

Pin the version alongside the seed if you need to reproduce earlier results. Nothing changes shape or column names, so no existing analysis code breaks.

Features

gen_recurrent_events — events that repeat within a subject. Three processes matching the models the data is analysed with: ag (Andersen-Gill), pwp_tt and pwp_gt (Prentice-Williams-Peterson in total and gap time, the latter resetting the clock at each event). Exponential, Weibull and Gompertz baselines. Returns counting-process intervals.

simulate() — returns the frame, the SimulationConfig that produced it, and a truth mapping of what a real dataset never contains: coefficients actually used, covariates, linear predictors, latent event and censoring times, cure status, cause-specific and transition times, and the tdcm crossover the frame cannot express.

from gen_surv import simulate

result = simulate("cphm", n=1000, beta=0.5, covariate_range=2.0,
                  model_cens="uniform", cens_par=1.0, seed=42)

result.truth["event_time"]       # when each subject would have failed
result.truth["censoring_time"]   # what censoring hid

Several generators draw their coefficients when you omit them. result.truth["betas"] is the only way to learn what they were.

gen_surv.baseline — a BaselineHazard protocol with exponential, Weibull, Gompertz, log-logistic and piecewise-constant families. A generator written against it accepts any shape, so gen_recurrent_events already samples from families it does not name.

The CLI reaches every model. cmm, thmm and tdcm had no way to pass their parameters and failed with a TypeError while being advertised as valid.

Bug fixes

  • gen_piecewise_exponential drew middle-interval events at the wrong hazard — the last rate rather than the interval's own. With breakpoints [1, 3] and rates [0.5, 2.0, 0.2], the hazard on [1, 3) measured 0.201 against a declared 2.0. Only two or more breakpoints were affected.
  • gen_tdcm had a sign error in its post-crossover inversion, placing events drawn after the covariate switch before it and, for a large enough beta[1], at negative times — 6,886 of 50,000 subjects at beta[1] = 1.0.
  • tdcov described the wrong interval: a subject censored before its crossover was recorded as having switched.
  • summarize_survival_dataset crashed on Windows, its default verbose report printing characters a legacy code page cannot encode.
  • GenSurvDataGenerator was not scikit-learn compatible: clone silently dropped every model parameter, so pipelines and GridSearchCV produced estimators that failed on first use.

Documentation

Rebuilt on MkDocs with Material and mkdocstrings, replacing Sphinx. The previous API reference was written in mkdocstrings syntax that Sphinx rendered as literal YAML, so it contained no signatures and no docstrings at all. Read the Docs is retired; https://diogoribeiro7.github.io/genSurvPy/ is the single home, rebuilt from each release tag.

Per-model pages now carry the parameters, the mathematics, a worked example and a check that the parameters can be recovered from the generated data.

Testing

  • The frozen-output regression suite had been inert — tests/baselines was empty, so every case skipped while the run reported success, and it covered four of twelve generators. Baselines are committed for all twelve, a missing one now fails, and the tolerance is 1e-12.
  • Distribution tests for every generator, by probability integral transform.
  • The documentation's examples are executed and their pasted output compared against what they print; the shipped scripts and notebooks are run.

Packaging

PEP 621 metadata, clearing three Poetry deprecations; the wheel gains License-Expression: MIT and ships LICENSE. poetry.lock is now committed.

Install: pip install gen-surv==2.1.0