gen_surv

gen_surv is a Python package for simulating survival data under a variety of models, inspired by the R package genSurv

https://github.com/diogoribeiro7/gensurvpy

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.5%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

gen_surv is a Python package for simulating survival data under a variety of models, inspired by the R package genSurv

Basic Info
  • Host: GitHub
  • Owner: DiogoRibeiro7
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 174 KB
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 20
Created 11 months ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation

README.md

gen_surv

Coverage Docs PyPI Tests Python

gen_surv is a Python library for simulating survival data and producing visualizations under a wide range of statistical models. Inspired by the R package genSurv, it offers a unified interface for generating realistic datasets for research, teaching and benchmarking.


Features

  • Cox proportional hazards model (CPHM)
  • Accelerated failure time models (log-normal, log-logistic, Weibull)
  • Continuous-time multi-state Markov model (CMM)
  • Time-dependent covariate model (TDCM)
  • Time-homogeneous hidden Markov model (THMM)
  • Mixture cure and piecewise exponential models
  • Competing risks generators (constant and Weibull hazards)
  • Visualization helpers built on matplotlib and lifelines
  • Scikit-learn compatible data generator
  • Conversion utilities for scikit-survival
  • Command-line interface for dataset creation and visualization

Installation

Requires Python 3.10 or later.

Install the latest release from PyPI:

bash pip install gen-surv

gen_surv installs matplotlib and lifelines for visualization. Support for scikit-survival is optional; install it to enable integration with the scikit-survival ecosystem or to run the full test suite:

bash pip install gen-surv[dev]

To develop locally with all extras:

bash git clone https://github.com/DiogoRibeiro7/genSurvPy.git cd genSurvPy poetry install --with dev

On Debian/Ubuntu you may need build-essential gfortran libopenblas-dev to build scikit-survival.

Development

Before committing changes, install the pre-commit hooks and run the tests:

bash pre-commit install pre-commit run --all-files pytest

Tests that depend on optional packages such as scikit-survival are skipped automatically when those packages are missing.

Usage

Python API

```python from gensurv import generate, exportdataset, tosksurv from gensurv.visualization import plotsurvivalcurve

sim = generate( model="cphm", n=100, beta=0.5, covariaterange=2.0, modelcens="uniform", cens_par=1.0, )

plotsurvivalcurve(sim) exportdataset(sim, "survivaldata.rds")

convert for scikit-survival

sksdataset = tosksurv(sim) ```

See the usage guide for more examples.

Command Line

Generate datasets and plots without writing Python code:

```bash python -m gen_surv dataset cphm --n 1000 -o survival.csv

python -m gensurv visualize survival.csv --output survivalplot.png ```

visualize accepts custom column names via --time-col and --status-col and can stratify by group with --group-col.

Supported Models

| Model | Description | |-------|-------------| | CPHM | Cox proportional hazards | | AFT | Accelerated failure time (log-normal, log-logistic, Weibull) | | CMM | Continuous-time multi-state Markov | | TDCM | Time-dependent covariates | | THMM | Time-homogeneous hidden Markov | | Competing Risks | Multiple event types with cause-specific hazards | | Mixture Cure | Models long-term survivors | | Piecewise Exponential | Flexible baseline hazard via intervals |

More details on each algorithm are available in the Algorithms page. For additional background, see the theory guide.

Documentation

Full documentation is hosted on Read the Docs. It includes installation instructions, tutorials, API references and a bibliography.

To build the docs locally:

bash cd docs make html

Open build/html/index.html in your browser to view the result.

License

This project is licensed under the MIT License. See LICENSE for details.

Citation

If you use gen_surv in your research, please cite the project using the metadata in CITATION.cff.

Author

Diogo RibeiroESMAD - Instituto Politécnico do Porto

Owner

  • Name: Diogo Ribeiro
  • Login: DiogoRibeiro7
  • Kind: user
  • Location: Portugal

Data Scientist 💡| Math Lover 🔢

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it using the metadata below."

# Basic information
preferred-citation:
  type: software
  title: "gen_surv"
  version: "1.0.9"
  url: "https://github.com/DiogoRibeiro7/genSurvPy"
  authors:
    - family-names: Ribeiro
      given-names: Diogo
      alias: DiogoRibeiro7
      orcid: "https://orcid.org/0009-0001-2022-7072"
      affiliation: "ESMAD - Instituto Politécnico do Porto"
      email: "dfr@esmad.ipp.pt"
  license: "MIT"
  date-released: "2025-08-02"

GitHub Events

Total
  • Create event: 60
  • Release event: 12
  • Watch event: 3
  • Delete event: 43
  • Issue comment event: 16
  • Public event: 1
  • Push event: 123
  • Pull request review comment event: 5
  • Pull request review event: 14
  • Pull request event: 96
Last Year
  • Create event: 60
  • Release event: 12
  • Watch event: 3
  • Delete event: 43
  • Issue comment event: 16
  • Public event: 1
  • Push event: 123
  • Pull request review comment event: 5
  • Pull request review event: 14
  • Pull request event: 96

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 55
  • Average time to close issues: N/A
  • Average time to close pull requests: 1 day
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.13
  • Merged pull requests: 24
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 55
  • Average time to close issues: N/A
  • Average time to close pull requests: 1 day
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.13
  • Merged pull requests: 24
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • DiogoRibeiro7 (58)
Top Labels
Issue Labels
Pull Request Labels
codex (15)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 55 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 12
  • Total maintainers: 1
pypi.org: gen_surv

A Python package for simulating survival data, inspired by the R package genSurv

  • Versions: 12
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 55 Last month
Rankings
Dependent packages count: 9.3%
Average: 30.9%
Dependent repos count: 52.5%
Maintainers (1)
Last synced: 6 months ago