A Random Survival Forest implementation inspired by Ishwaran et al.
Project description
Random Survival Forest
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
$ pip install random-survival-forest
Contribute
Performance
This implemention is not optimized for being highly performant. It is programmed in pure python. If you have large datasets (large sample size) or use a very high number of trees, I suggest using the scikit-survival package.
Getting Started
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 (time until event occurs) must be index 1, event column index 0 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.
julian.alexander.spaeth@uni-hamburg..de
This package is open-source. If it helped you or you even use it comercially, I would be happy about a little support:
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for random_survival_forest-0.8.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3e883b093047896203c58bcd83431fe9e9ef2552f14cecdf723f65c5b905a50 |
|
MD5 | 91afa1460a78f993a7d3fcc98859a525 |
|
BLAKE2b-256 | ac08e2ff19f2c1a9b1a9c330b9d305885dfb7f0512184b43783bb3b21243a3c7 |
Hashes for random_survival_forest-0.8.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c783a15dd89a02447c665ee12c3d9f20efbf955b18a9eb3f31f58700e733a41c |
|
MD5 | 55f6d5f7faa8816094462e2ce0686474 |
|
BLAKE2b-256 | a8d1d8c7545dc18e60b470aff8d948d3646fc2c954252016901fb916f508d7c2 |