Metadata-Version: 2.3
Name: guanrank
Version: 0.1.1
Summary: GuanRank algorithm in Python
Author: d-laub
Author-email: d-laub <dlaub@ucsd.edu>
Requires-Dist: numpy>=1.24
Requires-Dist: numba>=0.59
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# guanrank

Python implementation of the GuanRank hazard ranking algorithm. Assigns a continuous hazard rank to each subject in a survival dataset — higher rank means higher risk of earlier event. Ranks can be used as regression targets for machine learning models in place of raw survival times.

## Citation

Huang et al. (2017). Complete hazard ranking to analyze right-censored data: An ALS survival study. *PLOS Comp Bio*, 15(1), 41–51. https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1005887

## Installation

```bash
pip install guanrank
# or with uv
uv add guanrank
```

## Usage

### Functional API

```python
from guanrank import guanrank

T = [5.0, 3.0, 8.0, 3.0]  # time-to-event or censoring times
E = [1,   1,   0,   0  ]  # 1 = event, 0 = censored

ranks = guanrank(T, E)
```

### Sklearn-style API (train/test split)

```python
from guanrank import GuanRank

gr = GuanRank()
train_ranks = gr.fit_transform(T_train, E_train)
test_ranks = gr.transform(T_test, E_test)
```

`fit` stores the training cohort's Kaplan-Meier curve; `transform` scores new subjects by comparing them against the training cohort.
