Skip to main content

Survival Analysis using Deep Learning for Prediction

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

survivaldnn-1.0.1.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

survivaldnn-1.0.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file survivaldnn-1.0.1.tar.gz.

File metadata

  • Download URL: survivaldnn-1.0.1.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.14

File hashes

Hashes for survivaldnn-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d2fda29acdcd89764b0b6692e870a534a9e9e49eadbf2b97b983920bc5dbccd4
MD5 b9f3e74a48f67df9180aa8476ca4c040
BLAKE2b-256 87e2ceeccaef7f88c2388dfa22774f99c7f15b760f03388fed21d8db905661b2

See more details on using hashes here.

File details

Details for the file survivaldnn-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: survivaldnn-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.14

File hashes

Hashes for survivaldnn-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cd98c4bc1203de5c702662ded5dc54d11dcc0ad25da9e26b9f1fe7514b122f9f
MD5 b01378c16b0db85f9c0d67d99780d606
BLAKE2b-256 03a8286d15a17425c26525f249fad437899f0911af7688042a0c9d2a14e72e58

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page