-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG] FIX Update power_transform docstring and add FutureWarning #12317
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
f361416
to
916f891
Compare
916f891
to
dffa9ce
Compare
Good catch but unfortunately, now that 0.20 is released we cannot change the default value of a public function like this. We probably need to go through a |
sklearn/preprocessing/data.py
Outdated
@@ -2865,51 +2866,60 @@ def power_transform(X, method='box-cox', standardize=True, copy=True): | |||
Parameters | |||
---------- | |||
X : array-like, shape (n_samples, n_features) | |||
The data to be transformed using a power transformation. | |||
The data used to estimate the optimal transformation parameters. |
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.
I'd leave the original version: ultimately the goal of power_transform()
is to transform X, the estimation of lambda is just an intermediary step.
|
||
standardize : boolean, default=True | ||
Set to True to apply zero-mean, unit-variance normalization to the | ||
transformed output. | ||
|
||
copy : boolean, optional, default=True | ||
Set to False to perform inplace computation. | ||
Set to False to perform inplace computation during transformation. | ||
|
||
Examples |
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.
Just noticed that the docstring is missing a Return
section
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.
added
sklearn/preprocessing/data.py
Outdated
NaNs are treated as missing values: disregarded to compute the statistics, | ||
and maintained during the data transformation. | ||
NaNs are treated as missing values: disregarded in fit, and maintained in | ||
transform. |
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.
nitpick: fit
and transform
(with double backticks)
Damn! We waited with the release for being able to do this! It's pretty bad we messed this up. |
Yeah sorry, my bad. It really slipped under my radar. |
@NicolasHug I should have caught that :-/ don't worry about it. |
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.
I don't think changing this in 0.20.1 accords with our backwards compatibility policies, unfortunately.
11da2a1
to
c899d07
Compare
Darn, now I wish I had taken a look sooner too. Updated it to a throw a |
59b0e62
to
c4abc8f
Compare
sklearn/preprocessing/data.py
Outdated
""" | ||
if method == 'warn': | ||
warnings.warn("The default value of 'method' will change from " | ||
"'box-cox' to 'yeo-johnson' in version 0.21. Set " |
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.
0.21? No, by default we'd say 0.23. I don't really see the advantage in doing differently here.
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.
misread that - fixed
For people that don't upgrade from 0.20.0 to 0.20.1 we can't suddenly
change it without warning in 0.21.
|
c4abc8f
to
4ac4b07
Compare
sklearn/preprocessing/data.py
Outdated
|
||
Returns | ||
------- | ||
X_trans : array-like, shape (n_samples, n_features) |
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.
dedent
sklearn/preprocessing/data.py
Outdated
method : str, (default='box-cox') | ||
The power transform method. Currently, 'box-cox' (Box-Cox transform) | ||
is the only option available. | ||
method : str, (default='warn') |
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.
don't specify default, as it is obscure. Explain below the current behaviour.
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.
Looks good apart from Joel's comments.
e52b471
to
62b43e3
Compare
Updated with Joel's notes. |
Thank you very much for the fix! |
@chang Please add an entry to the change log at |
Indeed, merged too quickly. This should be backported to v0.20.1rst I think. |
No worries, I can open a separate PR for the changelog tomorrow. |
No reason not to warn from 0.20.1, I just don't think we can fairly switch
without warning.
|
So the consensus is hurry this one into 0.20.1? Fine. as long as we remember to finish the deprecation in 0.23 (since the entry is now in 0.20.1, not 0.21.) |
As you prefer. Otherwise we could deprecate in 0.20.1 or 0.20.2 and remove in 0.22. As you prefer. |
Reference Issues/PRs
#11520
What does this implement/fix? Explain your changes.
Edit: A change to the defaults of a public method needs to go through the deprecation cycle. This PR has been revised to update the docstring and introduce a
FutureWarning
topower_transform()
.Looks like the function version of
PowerTransformer
wasn't updated when Yeo-Johnson was added. Just matching the defaults and updating the docstring with this PR. Congrats on the 0.20 release!!Any other comments?