Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cumulative_dynamic_auc or for Gridseach #192

Closed
felipe0216 opened this issue Apr 13, 2021 · 3 comments · Fixed by #230
Closed

cumulative_dynamic_auc or for Gridseach #192

felipe0216 opened this issue Apr 13, 2021 · 3 comments · Fixed by #230

Comments

@felipe0216
Copy link

felipe0216 commented Apr 13, 2021

I could be wrong here, but so far as I have seen, you can only use the concordance_index as a scoring metric when using GridsearchCV, RFECV, or similar wrappers. If you try to specify the "cumulative_dynamic_auc" or "concordance_index_ipcw" you will get an error as more parameters neeed to be specify than your default Scikit learn scoring, hence, getting an error. It is very possible that there might be an existing solution for this, so I apologise if that is the case.

So, according to the documentation you can incorporate GridSeachCV the following way.

from sklearn.exceptions import ConvergenceWarning
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler

coxnet_pipe = make_pipeline(
    StandardScaler(),
    CoxnetSurvivalAnalysis(l1_ratio=0.9, alpha_min_ratio=0.01, max_iter=100)
)
warnings.simplefilter("ignore", ConvergenceWarning)
coxnet_pipe.fit(Xt, y)

estimated_alphas = coxnet_pipe.named_steps["coxnetsurvivalanalysis"].alphas_
cv = KFold(n_splits=5, shuffle=True, random_state=0)
gcv = GridSearchCV(
    make_pipeline(StandardScaler(), CoxnetSurvivalAnalysis(l1_ratio=0.9)),
    param_grid={"coxnetsurvivalanalysis__alphas": [[v] for v in estimated_alphas]},
    cv=cv,
    error_score=0.5,
    n_jobs=4).fit(Xt, y)

cv_results = pd.DataFrame(gcv.cv_results_)

Ideally, it would be great to use those metrics like this:

cv = KFold(n_splits=5, shuffle=True, random_state=0)
gcv = GridSearchCV(
    make_pipeline(StandardScaler(), CoxnetSurvivalAnalysis(l1_ratio=0.9)),
    param_grid={"coxnetsurvivalanalysis__alphas": [[v] for v in estimated_alphas]},
    cv=cv,
    scorer = make_scorer(cumulative_dynamic_auc)
    error_score=0.5,
    n_jobs=4).fit(Xt, y)

cv_results = pd.DataFrame(gcv.cv_results_)
@sebp
Copy link
Owner

sebp commented Apr 14, 2021

cumulative_dynamic_auc or concordance_index_ipcw can currently not be used with GridSearchCV out of the box. I discussed some possible solutions to this in another issue.

@felipe0216
Copy link
Author

Hello @sebp ,

Thanks for your response, I have had al look at it, very useful although I didn't fully get it, if in the future you could include an example that would be great.

Lastly, scikit survival doesn't seem to support RFECV either, is that correct?

@sebp
Copy link
Owner

sebp commented Apr 15, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants