Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A Python package for survival analysis. The most flexible survival analysis package available. SurPyval can work with arbitrary combinations of observed, censored, and truncated data. SurPyval can also fit distributions with 'offsets' with ease, for example the three parameter Weibull distribution.

License

NotificationsYou must be signed in to change notification settings

derrynknife/SurPyval

Repository files navigation

surpyval logo

SurPyval - Survival Analysis in Python

actionsPyPI versionPyPI - Python VersionDocumentation StatusDOI

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:

MethodPara/Non-ParaObservedCensoredTruncated
MLEParametricYesYesYes
MPPParametricYesYesLimited
MSEParametricYesYesLimited
MOMParametricYesNoNo
MPSParametricYesYesNo
Kaplan-MeierNon-ParametricYesRight onlyLeft only
Nelson-AalenNon-ParametricYesRight onlyLeft only
Fleming-HarringtonNon-ParametricYesRight onlyLeft only
TurnbullNon-ParametricYesYesYes

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:

DistributionOffsetable
WeibullYes
NormalNo
LogNormalYes
GammaYes
BetaNo
UniformNo
ExponentialYes
Exponentiated WeibullYes
GumbelNo
LogisticNo
LogLogisticYes

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.

Install and Quick Intro

SurPyval can be installed via pip using the PyPIrepository

pip install surpyval

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

fromsurpyvalimportWeibullfromsurpyval.datasetsimportBoforsSteel# Fetch some data that comes with SurPyvaldata=BoforsSteel.dfx=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 maindocumentation.

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 watchcoverage report# Print coverage reportcoverage html# Make a html coverage report (really useful), open htmlcov/index.html

Pre-commit

  • Pip installpre-commit (it's inrequirements_dev.txt anyways)
  • Runpre-commit install which sets up the git hook scripts
  • If you'd like, runpre-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

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

About

A Python package for survival analysis. The most flexible survival analysis package available. SurPyval can work with arbitrary combinations of observed, censored, and truncated data. SurPyval can also fit distributions with 'offsets' with ease, for example the three parameter Weibull distribution.

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp