Using concordance_index_censored as scorer in GridSearchCV for scikit-survival

105 views Asked by At

In the documentation for scikit-survival it's stated that you can use GridSearchCV for hyperparameter search (hyperparameter optimization). Example code is shown for using as_concordance_index_ipcw_scorer (https://scikit-survival.readthedocs.io/en/stable/user_guide/evaluating-survival-models.html#Using-Metrics-in-Hyper-parameter-Search):

from sklearn.model_selection import GridSearchCV, KFold

from sksurv.metrics import (
    as_concordance_index_ipcw_scorer,
)

cv = KFold(n_splits=3, shuffle=True, random_state=1)

cv_param_grid = {
"estimator__max_depth": np.arange(1, 10, dtype=int),
}

gcv_cindex = GridSearchCV(
as_concordance_index_ipcw_scorer(rsf_gbsg, tau=gbsg_times[-1]),
param_grid=cv_param_grid,
cv=cv,
n_jobs=4,
).fit(gbsg_X, gbsg_y)

How would you modify the code to make it work with Harrell’s concordance index (concordance_index_censored) as the scorer instead (https://scikit-survival.readthedocs.io/en/stable/api/generated/sksurv.metrics.concordance_index_censored.html)?

0

There are 0 answers