Skip to main content

Build PyPi Downloads License

Survival Analysis using Deep Learning for Prediction


SurvivalDNN

Documentation

SurvivalDNN is a library for survival analysis using deep learning, with a focus on prediction tasks and ease-of-use. Survival analysis models the time until events occur, for example the failure time of industrial components, patient survival times in medicine, customer churn in business, and credit risk in finance.

Getting Started

Install from PyPi: $ pip install survivaldnn

Usage

  1. Specify the model architecture, loss function, and other hyperparameters
from survivaldnn import SurvivalDNNModel

model = SurvivalDNNModel()

# Default: Residual network with negative loglikelihood loss
model.compile(
    numFeatures,
    numSupport=100,
    loss='loglik',
    architecture='resnet',
    layers=3
)
  1. Train the model
model.fit(X, Y,
          numSupport=100,
          epochs=100)
  1. Make predictions of interest
# Estimated time until failure
model.predict(X)

# Estimated time until failure, given that `elapsed` time has occurred
model.predict(X, elapsed)

# Estimated full survival function and support
survFunc, support = model.predict_survival_function(X)

For a more in-depth example, see this notebook.

Technical Note

This library builds on and draws from other proposed methodologies such as DeepSurv (Katzman et al., 2018), Nnet-Survival (Gensheimer and Narasimhan, 2018), and DNNSurv (Zhao and Feng, 2021), with a few modifications for practical usage, stability during training, and efficiency.

With discrete-time survival models, the outcome space is discretized into a finite number of support points ${t_1,\dots, t_k}$ with $t_{i-1} < t_{i}$ such that
$$\text{supp}(Y) = \bigcup_{i=1}^{k} (t_{i-1}, t_i]$$
Deep learning approaches to survival analysis often model the conditional survival probabilities $P(Y > t_j|X, Y > t_{j-1})$, or the probability of surviving each time interval given that an individual has survived up to the previous interval. In this library, the outputs of the neural network are instead a $k$-dimensional vector that models the survival function directly:
$$\Big( P(Y > t_1|X), P(Y > t_2|X), \dots, P(Y > t_k|X) \Big)$$
which is done by enforcing monotonicity restrictions in the final layer, such that $P(Y > t_{i-1}|X) \geq P(Y > t_i|X)$. The main reasoning for doing so is that for prediction tasks, interest is typically on statistics based on features of $P(Y > t_i|X)$. We can of course still obtain the marginal survival probabilities using the conventional approach with
$$P(Y > t_j|X) = \prod_{i}^{j} P(Y > t_i|X, Y > t_{i-1})$$
However this can be numerically unstable and can compound small errors especially when the number of support points is large. By modeling the survival function directly with the additional structure from enforcing monotonicity, this implementation can be more stable during training as well as being more computationally efficient for large-scale prediction tasks.

References

Gensheimer, M. F., & Narasimhan, B. (2019). A scalable discrete-time survival model for neural networks. PeerJ, 7, e6257. https://doi.org/10.7717/peerj.6257

Katzman, J. L., Shaham, U., Cloninger, A., Bates, J., Jiang, T., & Kluger, Y. (2018). DeepSurv: Personalized treatment recommender system using a Cox proportional hazards deep neural network. BMC Medical Research Methodology, 18(1), 24. https://doi.org/10.1186/s12874-018-0482-1

Zhao, L., & Feng, D. (2020). Deep neural networks for survival analysis using pseudo values. IEEE Journal of Biomedical and Health Informatics, 24(11), 3308–3314. https://doi.org/10.1109/JBHI.2020.2980204

Metadata

Release files for SurvivalDNN 1.0.1

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

Source distribution (sdist)

Source distribution for SurvivalDNN 1.0.1
File Size Uploaded Provenance Actions
survivaldnn-1.0.1.tar.gz 11.1 kB Without provenance Details for survivaldnn-1.0.1.tar.gz

Built distribution (wheel)

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

Total release size: 22.3 kB

Release files / survivaldnn-1.0.1.tar.gz

Download URL survivaldnn-1.0.1.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d2fda29acdcd89764b0b6692e870a534a9e9e49eadbf2b97b983920bc5dbccd4
BLAKE2b-256 checksum
How to use checksums
87e2ceeccaef7f88c2388dfa22774f99c7f15b760f03388fed21d8db905661b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.14

Release files / survivaldnn-1.0.1-py3-none-any.whl

Download URL survivaldnn-1.0.1-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd98c4bc1203de5c702662ded5dc54d11dcc0ad25da9e26b9f1fe7514b122f9f
BLAKE2b-256 checksum
How to use checksums
03a8286d15a17425c26525f249fad437899f0911af7688042a0c9d2a14e72e58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.14

Security for SurvivalDNN 1.0.1

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

1.0.1 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