Skip to content
Survival analysis with PyTorch
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



Time-to-event prediction (survival analysis) with PyTorch.

The python package contains implementations of various survival models, some useful evaluation metrics, and a collection of event-time datasets.


The package contains implementations for


  • Cox-Time: a non-proportional relative risk model. [1] [example]

  • Cox-CC: a Cox-PH model. [1] [example]

  • DeepSurv: a Cox-PH model. [2] [example]

  • DeepHit (single event): a discrete time model. [3] [example]

Evaluation metrics:

  • Time-dependent concordance index. [4]

  • Brier score IPCW (inverse probability of censoring weighting). [5] [6]

  • Binomial log-likelihood IPCW.


  • For available data sets see datasets or the module pycox.datasets.


The package only works for python 3.6+.

Before installing pycox, please install PyTorch (version >= 1.1). You can then run the following command to install the package, but we recommend to instead install from source (see below)

pip install -e git+git:// git+git://

Install from source

Installation from source depends on PyTorch, in addition to torchtuples which can be installed with

pip install git+git://

Next, clone and install with

git clone
cd pycox
python install


[1] Håvard Kvamme, Ørnulf Borgan, and Ida Scheel. Time-to-event prediction with neural networks and Cox regression. Journal of Machine Learning Research, 20(129):1–30, 2019. [paper]

[2] Jared L. Katzman, Uri Shaham, Alexander Cloninger, Jonathan Bates, Tingting Jiang, and Yuval Kluger. Deepsurv: personalized treatment recommender system using a Cox proportional hazards deep neural network. BMC Medical Research Methodology, 18(1), 2018. [paper]

[3] Changhee Lee, William R Zame, Jinsung Yoon, and Mihaela van der Schaar. Deephit: A deep learning approach to survival analysis with competing risks. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018. [paper]

[4] Laura Antolini, Patrizia Boracchi, and Elia Biganzoli. A time-dependent discrimination index for survival data. Statistics in Medicine, 24(24):3927–3944, 2005. [paper]

[5] Erika Graf, Claudia Schmoor, Willi Sauerbrei, and Martin Schumacher. Assessment and comparison of prognostic classification schemes for survival data. Statistics in Medicine, 18(17-18):2529–2545, 1999. [paper]

[6] Thomas A. Gerds and Martin Schumacher. Consistent estimation of the expected brier score in general survival models with right-censored event times. Biometrical Journal, 48 (6):1029–1040, 2006. [paper]

You can’t perform that action at this time.