Survival Analysis using Deep Learning for Prediction
Project description
Survival Analysis using Deep Learning for Prediction
SurvivalDNN
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
- 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
)
- Train the model
model.fit(X, Y,
numSupport=100,
epochs=100)
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file survivaldnn-1.0.0.tar.gz.
File metadata
- Download URL: survivaldnn-1.0.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c066a4fee8340021360688d2ba130194a6dd85ba67b71936d1106f73b4f88a78
|
|
| MD5 |
906fef852c0a3e081245b82850fc5a33
|
|
| BLAKE2b-256 |
387ddb26e31b30c19edc9e052968be2c82f1434946f45db506ff4cea03ba9ca8
|
File details
Details for the file survivaldnn-1.0.0-py3-none-any.whl.
File metadata
- Download URL: survivaldnn-1.0.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af62250fcf856151f69c462730cecd93f0170d45f124940cb59db0a686d6e03d
|
|
| MD5 |
e449907a6dcf8c1b24d95b5cadb696b0
|
|
| BLAKE2b-256 |
ea8bd92261dd5346335e442ac9b3cd48340d75e3e6467e7adf1e41f0ab43bbf1
|