Skip to main content

EnSurv

EnSurv fits a generative model for right-censored time-to-event data. A PyTorch generator learns to draw event times conditional on covariates. These draws can be summarized as patient-level survival curves, medians, quantiles, or sample distributions.

Installation

After the first PyPI release, install EnSurv with Python 3.11 or newer.

python -m pip install ensurv

From a source checkout, use python -m pip install .. Add the workflow extra for data preprocessing, evaluation metrics, and diagnostic plots (ensurv[workflow] or .[workflow]).

Fit and predict

import numpy as np
from ensurv import EnSurv

rng = np.random.default_rng(7)
X = rng.normal(size=(128, 2))
event_time = rng.lognormal(4.0 + 0.5 * X[:, 0], 0.4)
censor_time = rng.uniform(25, 140, size=len(X))
Y = np.minimum(event_time, censor_time)
Delta = (event_time <= censor_time).astype(int)

model = EnSurv(device="cpu", random_state=7)
model.fit(X, Y, Delta, epochs=10, m=8, B=8)

times = np.linspace(0, model.tau_, 50, endpoint=False)
survival = model.predict_survival(X[:3], times, nsample=500, random_state=7)
print(survival.shape)  # (3, 50)

Y contains positive observed follow-up times. Delta=1 marks an observed event and Delta=0 marks right censoring. The default fitted horizon model.tau_ is the largest observed event time in the training data. Keep raw survival queries below that horizon or pass restricted=True for the horizon-restricted distribution.

Examples and documentation

  • examples/EnSurv_SUPPORT_Example.ipynb walks through three-fold cross-validation, metrics, and diagnostics on public SUPPORT data.
  • simulations/ contains the asymptotic and synthetic prediction experiments.
  • docs/ contains the Sphinx user guide and API reference. Build it with python -m pip install ".[docs,workflow]" followed by python -m sphinx -W -b html docs docs/_build/html.
  • RELEASE.md covers building distributions, publishing to PyPI, and hosting the docs on Read the Docs.

Metadata

Release files for ensurv 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ensurv 0.1.0
File Size Uploaded Provenance Actions
ensurv-0.1.0.tar.gz 435.0 kB Without provenance Details for ensurv-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ensurv 0.1.0
File Interpreter ABI Platform Actions
ensurv-0.1.0-py3-none-any.whl Python 3 none any Details for ensurv-0.1.0-py3-none-any.whl

Total release size: 484.0 kB

Release files / ensurv-0.1.0.tar.gz

Download URL ensurv-0.1.0.tar.gz
Size 435.0 kB
Tags Source
SHA-256 checksum
How to use checksums
8741a9d08f0e4906b914e4b6112e4cf3f30d91fff9d216b94bf6ad1f48ca87f8
BLAKE2b-256 checksum
How to use checksums
a3356eb71243f8e6edc89db67b3500d6c4ccbb3ef00a4a774947ae56643fd37e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / ensurv-0.1.0-py3-none-any.whl

Download URL ensurv-0.1.0-py3-none-any.whl
Size 49.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e35c1557485660cb2545ecac5ea89b39870765b93e79bb2da3c14f7049fca5c
BLAKE2b-256 checksum
How to use checksums
fe218398752a3e6e34bb652eb92f6fb097ae119b47d808fcade35875454237b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Security for ensurv 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page