-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG+1] Deprecate ridge_alpha param on SparsePCA.transform() #8137
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
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
@@ -10,6 +10,8 @@ | |||
from ..base import BaseEstimator, TransformerMixin | |||
from .dict_learning import dict_learning, dict_learning_online | |||
|
|||
import warnings |
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.
standard library imports should come first
@@ -148,7 +150,8 @@ def transform(self, X, ridge_alpha=None): | |||
|
|||
ridge_alpha: float, default: 0.01 | |||
Amount of ridge shrinkage to apply in order to improve | |||
conditioning. | |||
conditioning. Note that as of 0.19 this parameter is deprecated and |
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.
can use .. deprecated
sphinx markup
b296690
to
732c46c
Compare
Thanks @jnothman - made the changes |
@@ -150,6 +152,10 @@ def transform(self, X, ridge_alpha=None): | |||
Amount of ridge shrinkage to apply in order to improve | |||
conditioning. | |||
|
|||
.. deprecated:: 0.18 | |||
This parameter will be removed in 0.20. | |||
Specify `ridge_alpha` in the `SparsePCA` constructor. |
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.
single backticks don't do anything in RST. Use double backticks.
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.
Gotcha, thanks.
Really, you should set ridge_alpha to 'deprecated' by default, so that if a user explicitly passes |
Also, please check for a test where transform with ridge_alpha is used, and apply |
Travis failures are not your fault. |
@jnothman should the deprecated param be ignored, or should it still work for now? I've seen both patterns elsewhere in the codebase. |
Where do you see the deprecated param ignored? Yes, it should still work
for now.
…On 1 January 2017 at 12:08, Naoya Kanai ***@***.***> wrote:
@jnothman <https://github.com/jnothman> should the deprecated param be
ignored, or should it still work for now? I've seen both patterns elsewhere
in the codebase.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8137 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz63iLSOg4W46kKa5Ni7WRBJ9Cr8NQks5rNvyAgaJpZM4LYAA4>
.
|
But it shouldn't raise a warning unless it is used.
…On 1 January 2017 at 12:31, Joel Nothman ***@***.***> wrote:
Where do you see the deprecated param ignored? Yes, it should still work
for now.
On 1 January 2017 at 12:08, Naoya Kanai ***@***.***> wrote:
> @jnothman <https://github.com/jnothman> should the deprecated param be
> ignored, or should it still work for now? I've seen both patterns elsewhere
> in the codebase.
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#8137 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAEz63iLSOg4W46kKa5Ni7WRBJ9Cr8NQks5rNvyAgaJpZM4LYAA4>
> .
>
|
I saw it ignored in #7992: 2e79d88#r91984196 - but without being familiar with that issue I'm not sure if the context is different. |
The code you refer to wasn't accepted to be merged.
…On 1 January 2017 at 12:37, Naoya Kanai ***@***.***> wrote:
Where do you see the deprecated param ignored? Yes, it should still work
for now.
I saw it ignored in 2e79d88#r91984196
<2e79d88#r91984196>
- but without being familiar with that issue I'm not sure if the context is
different.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8137 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz66fL3llAObpzUXfzHlyS87wSlFelks5rNwNTgaJpZM4LYAA4>
.
|
Sorry, I think that comment was an outdated diff. But it looks like current master for that |
7f08889
to
409509b
Compare
@@ -70,6 +71,10 @@ def test_fit_transform(): | |||
spca_lasso.fit(Y) | |||
assert_array_almost_equal(spca_lasso.components_, spca_lars.components_) | |||
|
|||
# Test calling tranform with deprecated ridge_alpha parameter |
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.
Seeing the note about testing times with SparsePCA I stuck the deprecation test in here. Lmk if you think it's better to break it out.
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.
*transform
Here is fine. It's frustrating that this parameter was not already tested.
409509b
to
806901a
Compare
Sorry, I think that comment was an outdated diff. But it looks like
current master for that perplexity method still throws away the deprecated
arg. https://github.com/scikit-learn/scikit-learn/blob/
master/sklearn/decomposition/online_lda.py#L750
You're quite right. That needs to be fixed. A PR is welcome. That's also
good motivation for making sure to test deprecate depredations. The problem
there might have been that that parameter was never tested! :\
|
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.
Otherwise LGTM
@@ -70,6 +71,10 @@ def test_fit_transform(): | |||
spca_lasso.fit(Y) | |||
assert_array_almost_equal(spca_lasso.components_, spca_lars.components_) | |||
|
|||
# Test calling tranform with deprecated ridge_alpha parameter |
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.
*transform
Here is fine. It's frustrating that this parameter was not already tested.
@@ -70,6 +71,10 @@ def test_fit_transform(): | |||
spca_lasso.fit(Y) | |||
assert_array_almost_equal(spca_lasso.components_, spca_lars.components_) | |||
|
|||
# Test calling tranform with deprecated ridge_alpha parameter | |||
ridge_alpha = 0.01 | |||
assert_warns(DeprecationWarning, spca_lars.transform, Y, ridge_alpha) |
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 rather ridge_alpha=0.01
there, in part because really transform
should accept a second positional arg.
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.
Also added an example where ridge_alpha=None
to make sure it's handled properly
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.
but then I found more...
"deprecated since 0.19 and will be removed in 0.21. " | ||
"Specify ridge_alpha in the SparsePCA constructor.", | ||
DeprecationWarning) | ||
else: |
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 is going to break if ridge_alpha=None
is passed.
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.
Please test this case.
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 for the catch. In this case I have it reverting to self.ridge_alpha
.
@jnothman thanks for the detailed check, should be good now. Tests working again! |
Yes, again LGTM |
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.
+1 as my comment is not really important.
@@ -70,6 +71,10 @@ def test_fit_transform(): | |||
spca_lasso.fit(Y) | |||
assert_array_almost_equal(spca_lasso.components_, spca_lars.components_) | |||
|
|||
# Test that deprecated ridge_alpha parameter throws warning | |||
assert_warns(DeprecationWarning, spca_lars.transform, Y, ridge_alpha=0.01) | |||
assert_warns(DeprecationWarning, spca_lars.transform, Y, ridge_alpha=None) |
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 a niptick, it will be better to use assert_warns_message
with a part of the message (just to be sure it's the right message).
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 for the tip
c60db80
to
7cfe756
Compare
Thanks @naoyak! |
Thx @naoyak !!! |
Fixes #1975
Adds a
DeprecationWarning
if theridge_alpha
parameter is passed toSparsePCA.transform()
.