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

TPOTClassifier.set_params doesn't follow scikit-learn estimator API #739

Closed
TomAugspurger opened this issue Aug 9, 2018 · 4 comments
Closed
Labels

Comments

@TomAugspurger
Copy link
Contributor

Typically, calling old_estimator.set_params(new_param=foo) will copy all the other parameters from the old estimator, and only update new_param. Currently, TPOT will __init__ with the kwargs passed to new_param, and use the default or everything else.

Context of the issue

See http://scikit-learn.org/stable/developers/contributing.html#estimators and http://scikit-learn.org/stable/developers/contributing.html#get-params-and-set-params.

Process to reproduce the issue

clf = TPOTClassifier(random_state=0)
clf.set_params(n_jobs=-1).random_state
# output is None, the default random_state for TPOTClassifier

Expected result

>>> clf.set_params(n_jobs=-1).random_state
0

Possible fix

Hopefully just delete the custom set_params :) That may not be possible though, as it looks like there's some parameter handling logic in the __init__. That logic would need to be either moved to fit (and transform) or a helper method.

@weixuanfu weixuanfu added the bug label Aug 9, 2018
@rhiever
Copy link
Contributor

rhiever commented Aug 9, 2018

@amueller, any thoughts on how this should be resolved? Is it generally recommended to avoid parameter handling logic in the __init__ of an estimator? If so, we could move said logic to fit/predict.

@amueller
Copy link

amueller commented Aug 9, 2018 via email

@weixuanfu
Copy link
Contributor

weixuanfu commented Aug 9, 2018

OK, thanks! I think moving those logic to fit/predict is more clear way to fix this issue. I will submit a PR for it.

weixuanfu added a commit to weixuanfu/tpot that referenced this issue Aug 9, 2018
weixuanfu added a commit to weixuanfu/tpot that referenced this issue Aug 9, 2018
weixuanfu added a commit to weixuanfu/tpot that referenced this issue Aug 9, 2018
weixuanfu added a commit to weixuanfu/tpot that referenced this issue Aug 9, 2018
@weixuanfu
Copy link
Contributor

This issue should be fixed in TPOT 0.9.4. Please feel free to reopen this issue if you have any questions.

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

No branches or pull requests

4 participants