Skip to main content
surpyval logo

SurPyval - Survival Analysis in Python

actions PyPI version Python Version Documentation Status DOI

Yet another Python survival analysis tool.

This is another pure python survival analysis tool so why was it needed? The intent of this package was to closely mimic the scipy API as close as possible with a simple .fit() method for any type of distribution (parametric or non-parametric); other survival analysis packages don't completely mimic that API. Further, there is currently (at the time of writing) no pacakage that can take an arbitrary comination of observed, censored, and truncated data. Finally, surpyval is unique in that it can be used with multiple parametric estimation methods. This allows for an analyst to determine a distribution for the parameters if another method fails. The parametric methods available are Maximum Likelihood Estimation (MLE), Probability Plotting (MPP), Mean Square Error (MSE), Method of Moments (MOM), and Maximum Product of Spacing (MPS). Surpyval can, for each type of estimator, take the following types of input data:

Method Para/Non-Para Observed Censored Truncated
MLE Parametric Yes Yes Yes
MPP Parametric Yes Yes Limited
MSE Parametric Yes Yes Limited
MOM Parametric Yes No No
MPS Parametric Yes Yes No
Kaplan-Meier Non-Parametric Yes Right only Left only
Nelson-Aalen Non-Parametric Yes Right only Left only
Fleming-Harrington Non-Parametric Yes Right only Left only
Turnbull Non-Parametric Yes Yes Yes

SurPyval also offers many different distributions for users, and because of the flexible implementation adding new distributions is easy. Further, the power of SurPyval lay in the robust parameter estimation, as such, some distributions, those that are supported on the half real line, can be offset to make a three- or four-parameter version. The currently available distributions are:

Distribution Offsetable
Weibull Yes
Normal No
LogNormal Yes
Gamma Yes
Beta No
Beta (4 parameter) No
Uniform No
Exponential Yes
Exponentiated Weibull Yes
Gumbel No
Logistic No
LogLogistic Yes

This project spawned from a Reliaility Engineering project; due to the history of reliability engineers estimating parameters from a probability plot. SurPyval has continued this tradition to ensure that any parametric distribution can have the estimate plotted on a probability plot. These visualisations enable an analyst to get a sense of the goodness of fit of the parametric distribution with the non-parametric distribution.

The Model Landscape

SurPyval's models can be placed on a set of orthogonal axes. The table below cross-tabulates four of those axes — the time scale (continuous-time durations vs discrete-time trials), event recurrence, competing events, and covariates — against the estimation axis, and fills each cell with what can be used to implement it. The discrete-time models are single-event, not recurrent: Bernoulli is a single trial and Binomial is the sum of n such trials — neither is a recurrent-event process. A — marks a combination that is either not applicable (e.g. semiparametric estimation requires covariates) or not yet built.

Time Recurrence Events Covariates Parametric Semi-/Nonparametric
Continuous time Single event Single Without Weibull, Exponential, LogNormal, Gamma, … KaplanMeier, NelsonAalen, FlemingHarrington, Turnbull
Continuous time Single event Single With WeibullPH/WeibullAFT (PH/AFT/PO families) CoxPH
Continuous time Single event Competing Without CompetingRisks (CIF)
Continuous time Single event Competing With FineGray, CRPH
Continuous time Recurrent Single Without HPP, NHPP, CrowAMSAA, Duane, CoxLewis NonParametricCounting (MCF)
Continuous time Recurrent Single With ProportionalIntensityHPP, ProportionalIntensityNHPP
Continuous time Recurrent Competing Without CauseSpecificMCF
Continuous time Recurrent Competing With
Discrete time Single event Single Without Bernoulli (single trial), Binomial (n trials)
Discrete time Single event Single With use logistic / binomial regression (out of scope for this package)

Install and Quick Intro

SurPyval can be installed via pip using the PyPI repository

pip install surpyval

If you're familiar with survival analysis, and Weibull plotting, the following is a quick start.

from surpyval import Weibull
from surpyval.datasets import load_bofors_steel

# Fetch some data that comes with SurPyval
data = load_bofors_steel()

x = data['x']
n = data['n']

model = Weibull.fit(x=x, n=n, offset=True)
model.plot();

Weibull Data and Distribution

Documentation

SurPyval is well documented, and improving, at the main documentation.

Development

Dependencies

pip install -r requirements_dev.txt

Testing

Run the testing suite by simply executing:

pytest

or use coverage to get a coverage report:

coverage run -m pytest  # Run pytest under coverage's watch
coverage report         # Print coverage report
coverage html           # Make a html coverage report (really useful), open htmlcov/index.html

Pre-commit

  • Pip install pre-commit (it's in requirements_dev.txt anyways)
  • Run pre-commit install which sets up the git hook scripts
  • If you'd like, run pre-commit run --all-files to run the hooks on all files
  • When you go to commit, it will only proceed after all the hooks succeed

Contact

Email derryn if you want any features or to see how SurPyval can be used for you.

Release files for surpyval 0.19.0

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

Source distribution (sdist)

Source distribution for surpyval 0.19.0
File Size Uploaded
surpyval-0.19.0.tar.gz 2.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for surpyval 0.19.0
File Interpreter ABI Platform
surpyval-0.19.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.0 MB

Release files / surpyval-0.19.0.tar.gz

Download URL surpyval-0.19.0.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
25ace53eaa3ee55dcc02c77fd87eed4ea020a6cd518205573a157e3432042b75
BLAKE2b-256 checksum
How to use checksums
b8a0fdf66ad12ce343eaa1b4d188f0f888efcd00c08001c9692f76df5a148515
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.

Transparency log

Release files / surpyval-0.19.0-py3-none-any.whl

Download URL surpyval-0.19.0-py3-none-any.whl
Size 2.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
2c3d6a719c9ee157622c0e1847ff469243c19d05bd21c93b7169545151839d8b
BLAKE2b-256 checksum
How to use checksums
e101d70af2d6af8c773533ee001f17976301d73ac9ac8479e933784d8e546176
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.19.0 This release

2 release files

0.16.0

2 release files

0.15.2

2 release files

0.15.1

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.12.0

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.9

2 release files

0.10.8

2 release files

0.10.7

2 release files

0.10.6

2 release files

0.10.5

2 release files

0.10.4

2 release files

0.10.3

2 release files

0.10.2

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

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