Currently, I am doing a simulation to compare multiple models, my study doesn't require the best_estimator_
only the results from cv_results_
. The problem that I have is that I need the integrated_brier_score
and cumulative_dynamic_auc
for each combination of hyperparameters. As far as I know, I can't use sksurv.metrics.as_cumulative_dynamic_auc_scorer
and sksurv.metrics.as_integrated_brier_score_scorer
together to get from the same fit.
from sklearn.model_selection import GridSearchCV, KFold
from sklearn.feature_selection import SelectKBest
from sklearn.pipeline import Pipeline
from sksurv.datasets import load_veterans_lung_cancer
from sksurv.preprocessing import OneHotEncoder
from sksurv.linear_model import CoxnetSurvivalAnalysis
from sksurv.metrics import integrated_brier_score, cumulative_dynamic_auc
from sklearn.metrics import make_scorer
import pandas as pd
data_x, data_y = load_veterans_lung_cancer()
pipe = Pipeline([('encode', OneHotEncoder()),
('model', CoxnetSurvivalAnalysis(fit_baseline_model=True))])
param_grid = {'model__l1_ratio': [i/10 for i in range(1, 11)]}
cv = KFold(n_splits=3, random_state=1, shuffle=True)
gcv = GridSearchCV(pipe, param_grid, return_train_score=True, cv=cv,
refit = False,
scoring={"integrated_brier_score": make_scorer(integrated_brier_score),
"cumulative_dynamic_auc": make_scorer(cumulative_dynamic_auc)})
gcv.fit(data_x, data_y)
results = pd.DataFrame(gcv.cv_results_)
When I run the previous code, I got this error.
return self._sign * self._score_func(y_true, y_pred, **self._kwargs)
TypeError: integrated_brier_score() missing 2 required positional arguments: 'estimate' and 'times'