A Random Survival Forest implementation for python inspired by Ishwaran et al. - Easily understandable, adaptable and extendable.

julianspaeth, updated πŸ•₯ 2022-10-19 12:06:06

Random Survival Forest

DOI

The Random Survival Forest package provides a python implementation of the survival prediction method originally published by Ishwaran et al. (2008).

Reference: Ishwaran, H., Kogalur, U. B., Blackstone, E. H., & Lauer, M. S. (2008). Random survival forests. The annals of applied statistics, 2(3), 841-860.

Installation

sh $ pip install random-survival-forest

Contribute

  • Source Code: https://github.com/julianspaeth/random-survival-forest

Getting Started

```python import time

from lifelines import datasets from sklearn.model_selection import train_test_split

from random_survival_forest.models import RandomSurvivalForest from random_survival_forest.scoring import concordance_index

rossi = datasets.load_rossi()

Attention: duration column must be index 0, event column index 1 in y

y = rossi.loc[:, ["arrest", "week"]] X = rossi.drop(["arrest", "week"], axis=1) X, X_test, y, y_test = train_test_split(X, y, test_size=0.33, random_state=10)

print("Start training...") start_time = time.time() rsf = RandomSurvivalForest(n_estimators=10, n_jobs=-1, random_state=10) rsf = rsf.fit(X, y) print(f'--- {round(time.time() - start_time, 3)} seconds ---') y_pred = rsf.predict(X_test) c_val = concordance_index(y_time=y_test["week"], y_pred=y_pred, y_event=y_test["arrest"]) print(f'C-index {round(c_val, 3)}') ```

Feedback

If you are having issues or feedback, please let me know. I am happy to fix some bug or implement feature requests.

[email protected]

This package is open-source. If it helped you or you even use it comercially, I would be happy about a little support:

"Buy Me A Coffee"

License

MIT

Releases

v0.8.1 2022-10-19 07:50:38

  • Fix bug with floating points in timeline

Create doi 2021-07-14 13:10:26

random-survival-forest 0.1-beta 2020-10-07 13:55:08

  • Fixing a bug in prediction
  • Adding a minimal example

random-survival-forest 0.7.2 2019-10-28 10:16:37

  • Add selection of parallelization backend

random-survival-forest 0.7.1 2019-10-27 14:05:21

  • Enhance performance of splitting
  • Fix issue with parallelization

random_survival_forest 0.7 2019-10-25 19:17:00

  • Important bug fixes
  • Models were not initialized properly.
Julian SpΓ€th

PHD Student @CosyBio @UHH

GitHub Repository

python survival-analysis survival-prediction random-survival-forests random-forest machine-learning