Passing sample weights to RandomSurvivalForest seems to have no influence on model outcome. Alterins sw in the code below does not impact the model score.
import numpy as np
from sklearn import set_config
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import OrdinalEncoder
from sksurv.datasets import load_gbsg2
from sksurv.preprocessing import OneHotEncoder
from sksurv.ensemble import RandomSurvivalForest
X, y = load_gbsg2()
grade_str = X.loc[:, "tgrade"].astype(object).values[:, np.newaxis]
grade_num = OrdinalEncoder(categories=[["I", "II", "III"]]).fit_transform(grade_str)
X_no_grade = X.drop("tgrade", axis=1)
Xt = OneHotEncoder().fit_transform(X_no_grade)
Xt.loc[:, "tgrade"] = grade_num
random_state = 20
X_train, X_test, y_train, y_test = train_test_split(Xt, y, test_size=0.25, random_state=random_state)
sw = np.where(y_train['cens'] == 1, 100, 1).astype(float)
rsf = RandomSurvivalForest(n_estimators=1000, min_samples_split=10, min_samples_leaf=15, n_jobs=-1, random_state=random_state,)
rsf.fit(X_train, y_train, sample_weight=sw)
rsf.score(X_test, y_test)
Expected Results
Model score to change with changing sw (for instance, 1 -> 100).
(may be related to this and this issues.)
Passing sample weights to
RandomSurvivalForest
seems to have no influence on model outcome. Alterinssw
in the code below does not impact the model score.Expected Results Model score to change with changing
sw
(for instance, 1 -> 100).Actual Results
Versions