Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

torch-survival Logo

torch-survival: A PyTorch-based library for Deep Survival Analysis

docs

torch-survival is a library built upon PyTorch and scikit-survival to make survival analysis using deep learning more accessible.

It's main goal is to implement a diverse set of deep learning methods for survival analysis using scikit-survival's API design, thus offering an improved out-of-box experience compared to existing libraries (see alternatives). In addition, it provides many common loss functions and metrics that may also be used standalone in other PyTorch-based projects.

Installation

torch-survival is available from PyPI and only depends on PyTorch, scikit-survival, and (for now) pycox. To install:

pip install torch-survival

For now only alpha releases are available.

Getting Started

Since the API design of torch-survival closely mimics that of scikit-survival (and in extension scikit-learn) it only takes a few lines of code to get started:

import pandas as pd
from sklearn.model_selection import train_test_split
from sksurv.datasets import load_whas500
from torch_survival.models import DeepSurv

X, y = load_whas500()
X = pd.get_dummies(X, drop_first=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)

model = DeepSurv(random_state=42, device='cpu')
model.fit(X_train, y_train)
c_index = model.score(X_test, y_test)

Implemented Models

This list summarizes the currently available models. We aim to steadily improve coverage and also welcome community contributions.

Alternatives

While torch-survival is the first comprehensive and production-ready library for deep survival analysis, there are other related libraries that you may want to consider:

  • pycox has building blocks for both continuous-time models (think DeepSurv) and discrete-time models (think DeepHit) but lacks ready-to-use models.
  • torchsurv implements loss functions and metrics with a heavier focus on statistical evaluation at the expense of computational performance.

Metadata

Release files for torch-survival 0.2.0a1

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

Source distribution (sdist)

Source distribution for torch-survival 0.2.0a1
File Size Uploaded Provenance Actions
torch_survival-0.2.0a1.tar.gz 18.9 kB Without provenance Details for torch_survival-0.2.0a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for torch-survival 0.2.0a1
File Interpreter ABI Platform Actions
torch_survival-0.2.0a1-py3-none-any.whl Python 3 none any Details for torch_survival-0.2.0a1-py3-none-any.whl

Total release size: 51.4 kB

Release files / torch_survival-0.2.0a1.tar.gz

Download URL torch_survival-0.2.0a1.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
67313ea096292917ff27a1581d227ac7ca94ea7cab9e8a2554bec6a680e28d87
BLAKE2b-256 checksum
How to use checksums
9e1f9b30260a6399189755ff77d10b84bdb1c44e5cff7e8345ca5a2455ea78c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / torch_survival-0.2.0a1-py3-none-any.whl

Download URL torch_survival-0.2.0a1-py3-none-any.whl
Size 32.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
949541b863984c79444ed1e7cf7519880ca7ecbc530dbf49c5d2ad5b0e938c20
BLAKE2b-256 checksum
How to use checksums
861d385dc8591690c26c5abf8659e0e3ff759700ae26c0f087aab8a3939a748f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for torch-survival 0.2.0a1

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.

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