Survival analysis for PyTorch, censoring included
pycox bundles neural survival models, evaluation metrics, and datasets into a single PyTorch toolkit so you don't have to hand-roll Cox regression and censoring logic.
What it does
pycox is a PyTorch-based library for survival analysis—predicting when an event such as failure, death, or churn will happen rather than simply whether it will. It packages nine methods, ranging from continuous-time Cox variants like DeepSurv and Cox-Time to discrete-time approaches like DeepHit and LogisticHazard, along with IPCW evaluation metrics and preprocessing utilities. The library also ships with several real-world event-time datasets accessible through a pycox.datasets module.
The interesting bit
Most deep-learning libraries treat classification or regression as the default; pycox treats right-censored data as first-class, offering both continuous and discrete hazard models under one roof. It is built on top of the author’s torchtuples training utility, which means the training loop abstractions are intentionally separated from the survival logic.
Key highlights
- Nine implemented methods including CoxPH (DeepSurv), Cox-Time, DeepHit, MTLR, and PCHazard, covering both continuous and discrete time.
- Evaluation suite with time-dependent concordance, IPCW Brier score, and administrative censoring metrics via
EvalSurv. - Built-in datasets such as METABRIC, FLCHAIN, and KKBox churn data available through
pycox.datasets. - Preprocessing tools and example notebooks that mix autoencoders with survival networks and CNNs on MNIST survival tasks.
Verdict
Worth a look if you are doing medical informatics, churn prediction, or reliability engineering with PyTorch and need more than a baseline Cox model. Skip it if you are already happy with scikit-survival or need a framework-agnostic solution.
Frequently asked
- What is havakv/pycox?
- pycox bundles neural survival models, evaluation metrics, and datasets into a single PyTorch toolkit so you don't have to hand-roll Cox regression and censoring logic.
- Is pycox open source?
- Yes — havakv/pycox is open source, released under the BSD-2-Clause license.
- What language is pycox written in?
- havakv/pycox is primarily written in Python.
- How popular is pycox?
- havakv/pycox has 989 stars on GitHub.
- Where can I find pycox?
- havakv/pycox is on GitHub at https://github.com/havakv/pycox.