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
API don't default get_params output to None in the future #14464
Conversation
@@ -127,9 +127,9 @@ class Pipeline(_BaseComposition): | |||
|
|||
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.
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_params
would usegetattr
to 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
clone
when__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