You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**gen_surv** is a Python package for simulating survival data under a variety of statistical models. It is inspired by the R package [genSurv](https://cran.r-project.org/package=genSurv) and provides a unified interface for generating realistic survival datasets.
**gen_surv** is a Python library for simulating survival data under a wide range of statistical models. Inspired by the R package [genSurv](https://cran.r-project.org/package=genSurv), it offers a unified interface for generating realistic datasets for research, teaching and benchmarking.
10
20
11
21
---
12
22
13
23
## Features
14
24
15
25
- Cox proportional hazards model (CPHM)
16
-
- Accelerated failure time models (log-normal, log-logistic)
26
+
- Accelerated failure time models (log-normal, log-logistic, Weibull)
17
27
- Continuous-time multi-state Markov model (CMM)
18
28
- Time-dependent covariate model (TDCM)
19
29
- Time-homogeneous hidden Markov model (THMM)
20
30
- Mixture cure and piecewise exponential models
21
31
- Competing risks generators (constant and Weibull hazards)
22
-
-Command-line interface and export utilities
32
+
-Visualization utilities for simulated datasets
23
33
- Scikit-learn compatible data generator
24
-
- Conversion helper for scikit-survival and lifelines
34
+
- Conversion helpers for scikit-survival and lifelines
35
+
- Command-line interface and export utilities
25
36
26
37
## Installation
27
38
@@ -45,8 +56,7 @@ cd genSurvPy
45
56
poetry install --with dev
46
57
```
47
58
48
-
Integration tests that rely on scikit-survival are automatically skipped if the
49
-
package is not installed.
59
+
Integration tests that rely on scikit-survival are automatically skipped if the package is not installed.
50
60
51
61
## Development Setup
52
62
@@ -57,10 +67,13 @@ pre-commit install
57
67
pre-commit run --all-files
58
68
```
59
69
60
-
## Quick Example
70
+
## Usage
71
+
72
+
### Python API
61
73
62
74
```python
63
-
from gen_surv import export_dataset, generate
75
+
from gen_surv import generate, export_dataset, to_sksurv
76
+
from gen_surv.visualization import plot_survival_curve
64
77
65
78
# basic Cox proportional hazards data
66
79
sim = generate(
@@ -72,45 +85,38 @@ sim = generate(
72
85
cens_par=1.0,
73
86
)
74
87
75
-
# save to an RDS file
88
+
plot_survival_curve(sim)
76
89
export_dataset(sim, "survival_data.rds")
77
-
```
78
-
79
-
You can also convert the resulting DataFrame for use with
80
-
[scikit-survival](https://scikit-survival.readthedocs.io) or
81
-
[lifelines](https://lifelines.readthedocs.io):
82
-
83
-
```python
84
-
from gen_surv import to_sksurv
85
90
91
+
# convert for scikit-survival
86
92
sks_dataset = to_sksurv(sim)
87
93
```
88
94
89
-
See the [usage guide](docs/source/getting_started.md) for more examples.
95
+
See the [usage guide](https://gensurvpy.readthedocs.io/en/latest/getting_started.html) for more examples.
|**AFT**| Accelerated failure time (log-normal, log-logistic, Weibull) |
111
+
|**CMM**| Continuous-time multi-state Markov |
112
+
|**TDCM**| Time-dependent covariates |
113
+
|**THMM**| Time-homogeneous hidden Markov |
114
+
|**Competing Risks**| Multiple event types with cause-specific hazards |
115
+
|**Mixture Cure**| Models long-term survivors |
116
+
|**Piecewise Exponential**| Flexible baseline hazard via intervals |
117
+
118
+
More details on each algorithm are available in the [Algorithms](https://gensurvpy.readthedocs.io/en/latest/algorithms.html) page. For additional background, see the [theory guide](https://gensurvpy.readthedocs.io/en/latest/theory.html).
119
+
114
120
## Documentation
115
121
116
122
Full documentation is hosted on [Read the Docs](https://gensurvpy.readthedocs.io/en/latest/). It includes installation instructions, tutorials, API references and a bibliography.
@@ -139,4 +145,3 @@ If you use **gen_surv** in your research, please cite the project using the meta
0 commit comments