Skip to content

Add option to return final cross-validation score in SequentialFeatureSelector #31473

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

Open
flaviorv opened this issue Jun 2, 2025 · 2 comments · May be fixed by #31483
Open

Add option to return final cross-validation score in SequentialFeatureSelector #31473

flaviorv opened this issue Jun 2, 2025 · 2 comments · May be fixed by #31483

Comments

@flaviorv
Copy link

flaviorv commented Jun 2, 2025

Describe the workflow you want to enable

Currently, when using SequentialFeatureSelector, it internally performs cross-validation to decide which features to select, based on the scoring function. However, the final cross-validation score (e.g., recall) is not returned by the SFS object.

Describe your proposed solution

Add an attribute (e.g., final_cv_score_) that stores the mean cross-validation score of the final model with the selected features. This would avoid having to run another cross-validation externally to get the final performance score.

Describe alternatives you've considered, if relevant

No response

Additional context

This feature would be especially useful when the scoring metric is expensive to compute, as it would avoid redundant cross-validation runs.

@flaviorv flaviorv added New Feature Needs Triage Issue requires triage labels Jun 2, 2025
@manitejagaddam
Copy link

Hey i gotch you, You need to calculate the final_cv_score_ in the SequentialFeatureSelector, so do you want the cv score for each epoch of the model or you need an entire cv score

Case 1) If you want and final_cv_score__ for each epoch you need to modify the scklearn code and add the accuracy field in it.

Case 2) If you want overall fianl_cv_score_ for entire model then use the accuracy_Score form the sklearn.metrics
You can get the predicted metrics from the method get_support the you can calulate the fianl_cv_score_

If you want modified SequentialFeatureSelector code with the field final_cv_score_ please check my github.

@betatim
Copy link
Member

betatim commented Jun 3, 2025

I think this sounds like a reasonable feature to add.

I tried to look around existing estimators to see what name is used for the fitted parameter. In TunedThresholdClassifier and GridSearchCV it is called best_score_. On the one hand it would be nice to have something consistent, on the other hand maybe here it isn't really a "best score"? Maybe something to address in a discussion in a PR.

@betatim betatim removed the Needs Triage Issue requires triage label Jun 3, 2025
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.

3 participants