Skip to content

[MRG] FIX Update power_transform docstring and add FutureWarning#12317

Merged
ogrisel merged 7 commits intoscikit-learn:masterfrom
chang:power-transform-default
Oct 10, 2018
Merged

[MRG] FIX Update power_transform docstring and add FutureWarning#12317
ogrisel merged 7 commits intoscikit-learn:masterfrom
chang:power-transform-default

Conversation

@chang
Copy link
Copy Markdown
Contributor

@chang chang commented Oct 7, 2018

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 to power_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?

@chang chang force-pushed the power-transform-default branch from f361416 to 916f891 Compare October 7, 2018 10:14
@chang chang force-pushed the power-transform-default branch from 916f891 to dffa9ce Compare October 7, 2018 10:16
@ogrisel
Copy link
Copy Markdown
Member

ogrisel commented Oct 7, 2018

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 FutureWarning cycle. We probably need to change the default to method='warn' wich would issue a FutureWarning: "power_transform(X, method='box-cox') will be changed to 'yeo-johnson' in version 0.23. Set the 'method' argument explicitly to silence this warning in the mean time."

----------
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.
Copy link
Copy Markdown
Member

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.

Set to False to perform inplace computation.
Set to False to perform inplace computation during transformation.

Examples
Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

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.
Copy link
Copy Markdown
Member

@NicolasHug NicolasHug Oct 7, 2018

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)

@amueller
Copy link
Copy Markdown
Member

amueller commented Oct 7, 2018

Damn! We waited with the release for being able to do this! It's pretty bad we messed this up.
I would consider doing this in 0.20.1 as a bug-fix?

@NicolasHug
Copy link
Copy Markdown
Member

Yeah sorry, my bad. It really slipped under my radar.

@amueller
Copy link
Copy Markdown
Member

amueller commented Oct 7, 2018

@NicolasHug I should have caught that :-/ don't worry about it.

Copy link
Copy Markdown
Member

@jnothman jnothman left a 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.

@chang chang force-pushed the power-transform-default branch 2 times, most recently from 11da2a1 to c899d07 Compare October 8, 2018 06:12
@chang chang changed the title [MRG] FIX Make power_transform() use Yeo-Johnson by default [MRG] FIX Update power_transform docstring and add FutureWarning Oct 8, 2018
@chang
Copy link
Copy Markdown
Contributor Author

chang commented Oct 8, 2018

Darn, now I wish I had taken a look sooner too. Updated it to a throw a FutureWarning that the default will be changed from 'box-cox' to 'yeo-johnson' in the next major version, 0.21.

@chang chang force-pushed the power-transform-default branch 2 times, most recently from 59b0e62 to c4abc8f Compare October 8, 2018 07:06
"""
if method == 'warn':
warnings.warn("The default value of 'method' will change from "
"'box-cox' to 'yeo-johnson' in version 0.21. Set "
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

misread that - fixed

@jnothman
Copy link
Copy Markdown
Member

jnothman commented Oct 8, 2018 via email

@chang chang force-pushed the power-transform-default branch from c4abc8f to 4ac4b07 Compare October 8, 2018 08:53

Returns
-------
X_trans : array-like, shape (n_samples, n_features)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dedent

method : str, (default='box-cox')
The power transform method. Currently, 'box-cox' (Box-Cox transform)
is the only option available.
method : str, (default='warn')
Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Member

@amueller amueller left a 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.

@chang chang force-pushed the power-transform-default branch from e52b471 to 62b43e3 Compare October 10, 2018 02:27
@chang
Copy link
Copy Markdown
Contributor Author

chang commented Oct 10, 2018

Updated with Joel's notes.

@ogrisel
Copy link
Copy Markdown
Member

ogrisel commented Oct 10, 2018

Thank you very much for the fix!

@ogrisel ogrisel merged commit bbb0d93 into scikit-learn:master Oct 10, 2018
@qinhanmin2014
Copy link
Copy Markdown
Member

@chang Please add an entry to the change log at doc/whats_new/v*.rst. Like the other entries there, please reference this pull request with :issue: and credit yourself (and other contributors if applicable) with :user:.

@ogrisel
Copy link
Copy Markdown
Member

ogrisel commented Oct 10, 2018

Indeed, merged too quickly. This should be backported to v0.20.1rst I think.

@ogrisel ogrisel added this to the 0.20.1 milestone Oct 10, 2018
@chang
Copy link
Copy Markdown
Contributor Author

chang commented Oct 10, 2018

No worries, I can open a separate PR for the changelog tomorrow.

@qinhanmin2014
Copy link
Copy Markdown
Member

Hmm, @ogrisel but the deprecation cycle here is from 0.21 to 0.23 and @jnothman don't think it's good to hurry this one into 0.20.1?

@jnothman
Copy link
Copy Markdown
Member

jnothman commented Oct 10, 2018 via email

@chang chang deleted the power-transform-default branch October 10, 2018 18:44
@qinhanmin2014
Copy link
Copy Markdown
Member

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

@ogrisel
Copy link
Copy Markdown
Member

ogrisel commented Oct 11, 2018

As you prefer. Otherwise we could deprecate in 0.20.1 or 0.20.2 and remove in 0.22. As you prefer.

jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request Oct 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants