-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
API don't default get_params output to None in the future #14464
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
Conversation
jnothman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amueller would probably like this tightening of our __init__ expectations
|
|
||
| def __init__(self, steps, memory=None, verbose=False): | ||
| self.steps = steps | ||
| self._validate_steps() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was calling get_params before all attributes were set.
| pass | ||
|
|
||
| def fit(self, X, y=None): | ||
| return self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage is missing on lines like this, which I think is fine.
| return X | ||
|
|
||
| def diag(self, X): | ||
| return np.ones(X.shape[0]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coverage is missing on lines like this, which I think is fine.
rth
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jnothman !
amueller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
Even if affected users will see the warning maybe it's also worth adding a what's new entry? |
Reference Issues/PRs
Fixes #14461
What does this implement/fix? Explain your changes.
Previously, the default implementation of
get_paramswould usegetattrto retrieve a parameter value from an estimator, but would default to retrieve None if an AttributeError would otherwise have been raised.This can lead to surprising behaviour upon
clonewhen__init__is not correctly defined, as shown in #14461.I propose that we raise an AttributeError when a param cannot be retrieved by
getattr. This PR deprecates returning None, and raises a FutureWarning.Any other comments?
TODO: add tests