No project description provided
Project description
Survival data handler
import pandas as pd
from lifelines import CoxPHFitter
from lifelines.datasets import load_rossi
rossi = load_rossi()
cph = CoxPHFitter()
cph.fit(rossi, duration_col='week', event_col='arrest')
curves = cph.predict_survival_function(rossi).T
curves.columns = pd.to_timedelta(curves.columns.to_numpy() * 7, unit="D")
print(curves.head())
7 days 00:00:00 | 14 days 00:00:00 | 21 days 00:00:00 | 28 days 00:00:00 | 35 days 00:00:00 | 42 days 00:00:00 | 49 days 00:00:00 | 56 days 00:00:00 | 63 days 00:00:00 | 70 days 00:00:00 | |
---|---|---|---|---|---|---|---|---|---|---|
0 | 0.997616 | 0.99523 | 0.992848 | 0.990468 | 0.988085 | 0.985699 | 0.983305 | 0.971402 | 0.966614 | 0.964223 |
1 | 0.993695 | 0.987411 | 0.981162 | 0.974941 | 0.968739 | 0.962552 | 0.95637 | 0.926001 | 0.913958 | 0.907978 |
2 | 0.994083 | 0.988183 | 0.982314 | 0.976468 | 0.970639 | 0.96482 | 0.959004 | 0.930402 | 0.919043 | 0.913399 |
3 | 0.999045 | 0.998089 | 0.997133 | 0.996176 | 0.995216 | 0.994254 | 0.993287 | 0.98846 | 0.986508 | 0.985531 |
4 | 0.997626 | 0.99525 | 0.992878 | 0.990507 | 0.988135 | 0.985758 | 0.983374 | 0.97152 | 0.966752 | 0.96437 |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for survival_data_handler-2024.4.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ed0f1a3fee81eec5e43412aee70bf9a8fe43785ae252f439828a1ffae8f53b4 |
|
MD5 | ad33082bc6deb8c869d046b8884c40ce |
|
BLAKE2b-256 | 25b43b7f0ab2615a7298fb2d96ce8132392d2951e424fc518932f61945dd428f |
Close
Hashes for survival_data_handler-2024.4.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 802923f12a01ef3177d9a24f65a92f4c0091ea93b44e6695e03696ae02ec3d8b |
|
MD5 | 715d6e7d04792c9e76614cf1d3883a08 |
|
BLAKE2b-256 | 4290ed8bde313ca1bb09b46f1af6d13fa8982ac58b67c4290c0c75f24c9d4142 |