Tpot: TPOTClassifier.set_params doesn't follow scikit-learn estimator API

Created on 9 Aug 2018  Â·  4Comments  Â·  Source: EpistasisLab/tpot

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.

bug

All 4 comments

@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.

Traveling right now. But yeah, no validation or anything in init.

Sent from phone. Please excuse spelling and brevity.

On Thu, Aug 9, 2018, 16:14 Randy Olson notifications@github.com wrote:

@amueller https://github.com/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.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/EpistasisLab/tpot/issues/739#issuecomment-411772523,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAbcFg01NXfaLVTQRzmwY1tLa_KyEKUpks5uPEO9gaJpZM4V1wnf
.

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.

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

Was this page helpful?
0 / 5 - 0 ratings