Skip to content

set_params fn for pipeline to maintain order of parameters #10439

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
janvanrijn opened this issue Jan 9, 2018 · 2 comments
Closed

set_params fn for pipeline to maintain order of parameters #10439

janvanrijn opened this issue Jan 9, 2018 · 2 comments

Comments

@janvanrijn
Copy link
Contributor

Description

When I want to use the set param method to set a bunch of parameters, I can not control the order in which these are set. As a result, sometimes the program crashes, as setting hyperparameters requires a specific order.

e.g., SGD classifier requires the eta0 hyperparameter to be set to a value higher than 0 (which is the default) if a learning rate schedule other than optimal is chosen.

Steps/Code to Reproduce

from sklearn.linear_model import SGDClassifier
from sklearn.pipeline import Pipeline
from collections import OrderedDict

model = Pipeline(steps=[('estimator', SGDClassifier())])

hyperparameters = OrderedDict()
hyperparameters['estimator__eta0'] = 10 ** -5
hyperparameters['estimator__learning_rate'] = 'constant'

model.set_params(**hyperparameters)

print(model)

Expected Results

:)

Actual Results

This code crashes in 50% of the cases (depending on the order in which the hyperparameters are 'set')

Versions

Apparently this problem only occurs when the classifier is used in a pipeline, when using vanilla sgd there is no problem.
As the codeblock demonstrates, this problem occurs both when using a regular dict and an ordered dict.

@jnothman
Copy link
Member

jnothman commented Jan 9, 2018

Please give the actual error traceback. Please specify which version.

Some changes were recently made to set_params. Please try in master.

@jnothman
Copy link
Member

Closing given the lack of response at that related issues were fixed in #9945 and #9999

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

No branches or pull requests

4 participants