Random survival forest: an ensemble of censoring-aware survival trees.
Classes
class algorithms.survival.random_survival_forest.RandomSurvivalForest(Survival)
Random survival forest: an ensemble of survival trees.
__init__( self, n_estimators: int = 100, max_depth: Optional[int] = None, min_samples_split: int = 2, min_samples_leaf: int = 3, max_features = 'sqrt', random_state: Optional[int] = None, )
Overview
- For each tree, bootstrap-sample the data and (optionally) subsample the
-
Fit a
DecisionTreeRegressorto the
- Route the full training set through the tree and, per leaf, compute the
(time, event) pairs, evaluated at a common horizon \tau.
-
predict_riskroutes a sample to one leaf per tree and averages the
Theory
Within a leaf holding samples \{(t_i, \delta_i)\} the leaf risk is the Nelson-Aalen cumulative hazard up to a fixed horizon \tau (the median training event time):
Evaluating at an intermediate \tau — rather than at \infty — is what makes the leaf risk sensitive to when events happen: a leaf whose members fail early has accumulated most of its hazard by \tau, whereas a leaf whose members fail late is still close to zero. For a sample x landing in leaf \ell_t(x) of tree t, the ensemble risk is
A higher score means an earlier expected event, matching the Survival convention.
Parameters
n_estimators
max_depth
None = unlimited).
min_samples_split
min_samples_leaf
max_features
"sqrt", "log2", an int, a float fraction, or None for all features.
random_state
Attributes
estimators_
leaf_hazards_
horizon_, one per tree.
feature_subsets_
max_features_
horizon_
n_features_in_
fit().
Notes
Complexity:
- Fitting: O(T \cdot n \cdot p \cdot n \log n) for the base
- Prediction: O(T \cdot d) per sample.
- When the proportional-hazards assumption of Cox fails.
- When covariate effects are non_linear or interactive.
- Interpretability and coefficient inference are not required.
References
>>> from tuiml.algorithms.survival import RandomSurvivalForest
>>> import numpy as np
>>> rng = np.random.RandomState(0)
>>> X = rng.normal(size=(40, 2))
>>> time = np.exp(X[:, 0]) + rng.uniform(0, 1, size=40)
>>> event = np.ones(40)
>>> rsf = RandomSurvivalForest(n_estimators=10, random_state=0).fit(X, time, event)
>>> rsf.predict_risk(X[:3]).shape
(3,)
Methods
fit
(self, X, time, event) -> 'RandomSurvivalForest'
fit
(self, X, time, event) -> 'RandomSurvivalForest'
Fit the forest on right-censored survival data.
Parameters
X
time
event
Returns
self