Getting Started
This guide will help you install gen_surv and generate your first survival dataset.
Installation
From PyPI (Recommended)
pip install gen-surv
From Source
git clone https://github.com/DiogoRibeiro7/genSurvPy.git
cd genSurvPy
poetry install
Note
Some features and tests rely on optional packages such as
scikit-survival
. Install them with poetry install --with dev
or
pip install scikit-survival
(additional system libraries may be
required).
Basic Usage
The main entry point is the generate()
function:
from gen_surv import generate
# Generate Cox proportional hazards data
df = generate(
model="cphm", # Model type
n=100, # Sample size
beta=0.5, # Covariate effect
covariate_range=2.0, # Covariate range
model_cens="uniform", # Censoring type
cens_par=3.0 # Censoring parameter
)
print(df.head())
Understanding the Output
All models return a pandas DataFrame with at least these columns:
time
: Observed event or censoring timestatus
: Event indicator (1 = event, 0 = censored)Additional columns depend on the specific model
Command Line Usage
Generate datasets directly from the terminal:
# Generate CPHM data and save to CSV
python -m gen_surv dataset cphm --n 1000 -o survival_data.csv
# Print AFT data to stdout
python -m gen_surv dataset aft_ln --n 500
Next Steps
Explore the Tutorials for detailed examples
Check the API Reference for complete function documentation
Read about the 📘 Mathematical Foundations of gen_surv behind each model
Building the Documentation
To preview the documentation locally run:
cd docs
make html
More details about our Read the Docs configuration can be found in Read the Docs.