Skip to content

eurobios-mews-labs/survival-trees

Repository files navigation

LTRC Survival Forest

Alternative text

Install notice

To install the package you can run

python -m pip install git+https://eurobios-mews-labs/survival-trees.git

Usage

import numpy as np
from survival_trees import RandomForestLTRCFitter
from survival_trees.metric import time_dependent_auc
from lifelines import datasets
from sklearn.model_selection import train_test_split

# load dataset
data = datasets.load_larynx().dropna()
data["entry_date"] = data["age"]
data["time"] += data["entry_date"]
y = data[["entry_date", "time", "death"]]
X = data.drop(columns=y.columns.tolist())

# split dataset    
x_train, x_test, y_train, y_test = train_test_split(
    X, y, train_size=0.7)

# initialise and fit model    
model = RandomForestLTRCFitter(
    n_estimators=30,
    min_impurity_decrease=0.0000001,
    min_samples_leaf=3,
    max_samples=0.89)
model.fit(
    data.loc[x_train.index],
    entry_col="entry_date",
    duration_col="time",
    event_col='death'
)


survival_function = - np.log(model.predict_cumulative_hazard(
                    x_test).astype(float)).T

auc_cd = time_dependent_auc(
    - survival_function, 
    event_observed=y_test.loc[survival_function.index].iloc[:, 2],
    censoring_time=y_test.loc[survival_function.index].iloc[:, 1])

Benchmark

benchmark

References

Requirements

Having R compiler installed

Project

This implementation come from an SNCF DTIPG project and is developped and maintained by Eurobios Scientific Computation Branch and SNCF IR

drawing

drawing

Authors

  • Vincent LAURENT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published