-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Using Several Parameters with GridSearchCV #8243
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
Comments
Yes, this is a limitation of our API currently. One option is to use a parameter grid that only allows valid combinations, by using a list of parameter dicts wherein each setting is valid. A more robust forward-thinking solution might consider |
@jnothman Thank you, can you please elaborate a little bit more on the function-based approach? I am also considering to use the RandomizedSearchCV, but will probably face the same problem there, right? |
With randomized search you can't encode constraints between multiple
parameters, but you can use error_score=0.
The function-based approach would require someone changing the n_components
interface to allow it to be a function. It's not something we've generally
done, so it's probably on the scale of requiring an Enhancement Proposal to
suggest that this approach be used across the board.
You could potentially do something hacky like inherit from TruncatedSVD and
overwrite fit(X, y), such that it changes n_components depending on X.shape.
…On 31 January 2017 at 10:04, Fabian Retkowski ***@***.***> wrote:
@jnothman <https://github.com/jnothman> Thank you, can you please
elaborate a little bit more on the function-based approach? I am also
considering to use the RandomizedSearchCV, but will probably face the same
problem there, right?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8243 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz6zL8M94v7cetnyu1-urZvHQCvUctks5rXmxkgaJpZM4Lw5tC>
.
|
How about using |
When using (for example) the following transformators
CountVectorizer
TruncatedSVD
SelectKBest
with
GridSearchCV
it happens that it chooses a number forn_features
forCountVectorizer
that is less thann_components
forTruncatedSVD
ork
forSelectKBest
.This leads to an error:
ValueError: n_components must be < n_features
For
SelectKBest
I found a temporary solution:But there is no equivalent for
TruncatedSVD
.Is this behaviour intended? If yes, what can I do about this?
The text was updated successfully, but these errors were encountered: