Skip to content

ENH allow SelectKBest to select all features in a parameter search #1770

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

Closed
wants to merge 4 commits into from

Conversation

jnothman
Copy link
Member

Currently it is difficult to perform a grid-search over k for SelectKBest feature selection such that one parameter option is to ignore SelectKBest altogether (i.e. k == infty). If k > X.shape[1], it throws an error, and X.shape is not always known when the parameter grid is constructed. This patch allows one to use a parameter grid such as {'k': [5, 10, 20, 40, 80, SelectKBest.SELECT_ALL]} to include bypassing the selector as an option.

An alternative to this is to harness #1769 (together with param_grid being a list of dicts) to simply switch off the SelectKBest component. Perhaps neither solution is intuitive!

@larsmans
Copy link
Member

+1 for the feature, but there's no test.

@jnothman
Copy link
Member Author

Yes, well, as far as testing goes, it's very off-putting when you write a trivial patch and find the entire package lacks tests.

@larsmans
Copy link
Member

WDYM? There are tests in sklearn/feature_selection/tests.

@jnothman
Copy link
Member Author

Oh. I guess I am just not used to scikit-learn's test structures yet (or rather, I had been working with modules directly under sklearn that were tested in sklearn/tests so that's where I looked).

brb.

@larsmans
Copy link
Member

Merged as b80f6a8, thanks!

@larsmans larsmans closed this Mar 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants