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.
I'm having trouble with the examples you provide on the github and documentation sites. In a new Python 3.10 virtual environment I tried running:
from surpyval import Weibull
from surpyval.datasets import BoforsSteel
# Fetch some data that comes with SurPyval
data = BoforsSteel.df
x = data['x']
n = data['n']
model = Weibull.fit(x=x, n=n, offset=True)
model.plot();
and received the following error message:
AttributeError Traceback (most recent call last)
Cell In[2], line 5
2 from surpyval.datasets import BoforsSteel
4 # Fetch some data that comes with SurPyval
----> 5 data = BoforsSteel.df
7 x = data['x']
8 n = data['n']
AttributeError: 'BoforsSteel_' object has no attribute 'df'
From the documentation site I tried:
import surpyval as surv
import numpy as np
np.random.seed(10)
x = surv.Weibull.random(50, 30., 9.)
model = surv.Weibull.fit(x)
print(model)
model.plot();
and received the following error message:
ValueError Traceback (most recent call last)
Cell In[1], line 8
6 model = surv.Weibull.fit(x)
7 print(model)
----> 8 model.plot()
File ~/env/surpyval/lib/python3.10/site-packages/matplotlib/axes/_base.py:3194, in _AxesBase.grid(self, visible, which, axis, kwargs)
3192 _api.check_in_list(['x', 'y', 'both'], axis=axis)
3193 if axis in ['x', 'both']:
-> 3194 self.xaxis.grid(visible, which=which, kwargs)
3195 if axis in ['y', 'both']:
3196 self.yaxis.grid(visible, which=which, **kwargs)
File ~/env/surpyval/lib/python3.10/site-packages/matplotlib/axis.py:1660, in Axis.grid(self, visible, which, kwargs)
1657 if which in ['major', 'both']:
1658 gridkw['gridOn'] = (not self._major_tick_kw['gridOn']
1659 if visible is None else visible)
-> 1660 self.set_tick_params(which='major', gridkw)
1661 self.stale = True
File ~/env/surpyval/lib/python3.10/site-packages/matplotlib/axis.py:932, in Axis.set_tick_params(self, which, reset, **kwargs)
919 """
920 Set appearance parameters for ticks, ticklabels, and gridlines.
921
(...)
929 gridlines.
930 """
931 _api.check_in_list(['major', 'minor', 'both'], which=which)
--> 932 kwtrans = self._translate_tick_params(kwargs)
934 # the kwargs are stored in self._major/minor_tick_kw so that any
935 # future new ticks will automatically get them
936 if reset:
File ~/env/surpyval/lib/python3.10/site-packages/matplotlib/axis.py:1076, in Axis._translate_tickparams(kw, reverse)
1074 for key in kw:
1075 if key not in allowed_keys:
-> 1076 raise ValueError(
1077 "keyword %s is not recognized; valid keywords are %s"
1078 % (key, allowedkeys))
1079 kwtrans.update(kw)
1080 return kwtrans
I'm having trouble with the examples you provide on the github and documentation sites. In a new Python 3.10 virtual environment I tried running:
and received the following error message:
From the documentation site I tried:
and received the following error message:
List of packages installed and versions: Package Version
anyio 3.7.0 argon2-cffi 21.3.0 argon2-cffi-bindings 21.2.0 arrow 1.2.3 astor 0.8.1 asttokens 2.2.1 attrs 23.1.0 autograd 1.6.2 autograd-gamma 0.5.0 backcall 0.2.0 beautifulsoup4 4.12.2 bleach 6.0.0 cffi 1.15.1 comm 0.1.3 contourpy 1.1.0 cycler 0.11.0 debugpy 1.6.7 decorator 5.1.1 defusedxml 0.7.1 exceptiongroup 1.1.1 executing 1.2.0 fastjsonschema 2.17.1 fonttools 4.40.0 formulaic 0.6.2 fqdn 1.5.1 future 0.18.3 idna 3.4 interface-meta 1.3.0 ipykernel 6.23.3 ipython 8.14.0 ipython-genutils 0.2.0 ipywidgets 8.0.6 isoduration 20.11.0 jedi 0.18.2 Jinja2 3.1.2 jsonpointer 2.4 jsonschema 4.17.3 jupyter 1.0.0 jupyter_client 8.3.0 jupyter-console 6.6.3 jupyter_core 5.3.1 jupyter-events 0.6.3 jupyter_server 2.6.0 jupyter_server_terminals 0.4.4 jupyterlab-pygments 0.2.2 jupyterlab-widgets 3.0.7 kiwisolver 1.4.4 llvmlite 0.40.1 MarkupSafe 2.1.3 matplotlib 3.7.1 matplotlib-inline 0.1.6 mistune 3.0.1 nbclassic 1.0.0 nbclient 0.8.0 nbconvert 7.6.0 nbformat 5.9.0 nest-asyncio 1.5.6 notebook 6.5.4 notebook_shim 0.2.3 numba 0.57.1 numpy 1.24.4 numpy-indexed 0.3.7 overrides 7.3.1 packaging 23.1 pandas 2.0.2 pandocfilters 1.5.0 parso 0.8.3 pexpect 4.8.0 pickleshare 0.7.5 Pillow 9.5.0 pip 23.1.2 platformdirs 3.8.0 prometheus-client 0.17.0 prompt-toolkit 3.0.38 psutil 5.9.5 ptyprocess 0.7.0 pure-eval 0.2.2 pycparser 2.21 Pygments 2.15.1 pyparsing 3.1.0 pyrsistent 0.19.3 python-dateutil 2.8.2 python-json-logger 2.0.7 pytz 2023.3 PyYAML 6.0 pyzmq 25.1.0 qtconsole 5.4.3 QtPy 2.3.1 rfc3339-validator 0.1.4 rfc3986-validator 0.1.1 scipy 1.11.0 Send2Trash 1.8.2 setuptools 67.8.0 six 1.16.0 sniffio 1.3.0 soupsieve 2.4.1 stack-data 0.6.2 surpyval 0.10.10 terminado 0.17.1 tinycss2 1.2.1 tornado 6.3.2 traitlets 5.9.0 typing_extensions 4.6.3 tzdata 2023.3 uri-template 1.3.0 wcwidth 0.2.6 webcolors 1.13 webencodings 0.5.1 websocket-client 1.6.1 wheel 0.40.0 widgetsnbextension 4.0.7 wrapt 1.15.0