-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
[MRG+1] Deprecate Y parameter on transform() #8403
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
Codecov Report
@@ Coverage Diff @@
## master #8403 +/- ##
==========================================
- Coverage 95.47% 95.45% -0.03%
==========================================
Files 342 342
Lines 60907 60975 +68
==========================================
+ Hits 58154 58202 +48
- Misses 2753 2773 +20
Continue to review full report at Codecov.
|
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.
if y != 'deprecated'
will raise an error ify
is an array- this may be worth testing. Perhaps we should add a common test which checks that either you get an "invalid keyword"
TypeError
for passingy=something
or you get aDeprecationWarning
and it functions as usual.
@@ -289,6 +291,10 @@ def transform(self, X, y=None): | |||
Xa : {array, sparse matrix} | |||
Feature vectors; always 2-d. | |||
""" | |||
if y != 'deprecated': |
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 remove the dosctring entry for y
above (or mark it deprecated)
@@ -133,6 +135,11 @@ def transform(self, raw_X, y=None): | |||
Feature matrix, for use with estimators or further transformers. | |||
|
|||
""" | |||
if y != 'deprecated': |
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 update docstring.
sklearn/feature_extraction/text.py
Outdated
@@ -478,6 +479,11 @@ def transform(self, X, y=None): | |||
Document-term matrix. | |||
|
|||
""" | |||
if y != 'deprecated': |
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 update docstring.
sklearn/random_projection.py
Outdated
@@ -402,6 +402,11 @@ def transform(self, X, y=None): | |||
Projected array. | |||
|
|||
""" | |||
if y != 'deprecated': |
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 update docstring.
sklearn/tests/test_base.py
Outdated
@@ -300,7 +300,7 @@ def __init__(self, df=None, scalar_param=1): | |||
def fit(self, X, y=None): | |||
pass | |||
|
|||
def transform(self, X, y=None): | |||
def transform(self, X, y='deprecated'): |
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 drop y in tests
sklearn/tests/test_pipeline.py
Outdated
@@ -67,12 +67,12 @@ def set_params(self, **params): | |||
|
|||
|
|||
class NoInvTransf(NoTrans): | |||
def transform(self, X, y=None): | |||
def transform(self, X, y='deprecated'): |
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 drop y in tests
sklearn/tests/test_pipeline.py
Outdated
return X | ||
|
||
|
||
class Transf(NoInvTransf): | ||
def transform(self, X, y=None): | ||
def transform(self, X, y='deprecated'): |
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 drop y in tests
Thanks @jnothman
In this case, should we do something like:
|
Better assured doing isinstance(..., six.string_types) as elsewhere in the
codebase
…On 21 Feb 2017 7:35 am, "Tahar" ***@***.***> wrote:
Thanks @jnothman <https://github.com/jnothman>
if y != 'deprecated' will raise an error if y is an array
In this case, should we do something like:
if isinstance(y, np.ndarray) or y != 'deprecated':
warnings.warn("The parameter y on transform() is "
"deprecated since 0.19 and will be removed in 0.21",
DeprecationWarning)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8403 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz63q7GsfUtHqQM7joGxFwaIFY7CLbks5refj1gaJpZM4MFlT2>
.
|
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
sklearn/decomposition/base.py
Outdated
@@ -125,6 +128,11 @@ def transform(self, X, y=None): | |||
IncrementalPCA(batch_size=3, copy=True, n_components=2, whiten=False) | |||
>>> ipca.transform(X) # doctest: +SKIP | |||
""" | |||
if isinstance(y, np.ndarray) or y != 'deprecated': |
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.
missing not
Thanks @jnothman. I have fixed the issue you mentioned. Let me know if we need to add something else. |
I haven't looked in detail why |
in some ways i would rather it deprecated. but given how generic it is, it
might be okay to leave it there to support behaviour akin to
cross-decomposition models.
…On 22 Feb 2017 6:05 am, "Tahar" ***@***.***> wrote:
Thanks @lesteve <https://github.com/lesteve> . @jnothman
<https://github.com/jnothman> already suggested not to deprecate it for
now. Hope he has a moment to chime in.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8403 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz62N43v47YmEGjMIWnRX-7WrzXIPbks5rezV1gaJpZM4MFlT2>
.
|
Sorry did not get the last message, ignore this. Fair enough for not deprecating |
Can you add an entry in doc/whats_new.rst about the change? |
Thanks @lesteve . doc/whats_new.rst has been updated. |
Not sure what you did with your git history, but you will need to tidy it up before we can merge this PR. |
Thanks @lesteve. Ignore the last changes. |
doc/whats_new.rst
Outdated
@@ -255,6 +255,12 @@ API changes summary | |||
selection classes to be used with tools such as | |||
:func:`sklearn.model_selection.cross_val_predict`. | |||
:issue:`2879` by :user:`Stephen Hoover <stephen-hoover>`. | |||
|
|||
- Deprecate the ``Y`` parameter from ``transform`` method signature in |
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 you format this correctly. Respect the indentation whatever the number of spaces is. I don't think you need to list all the classes.
Also this is a small y
not a capital one
doc/whats_new.rst
Outdated
@@ -245,7 +245,7 @@ API changes summary | |||
(``n_samples``, ``n_classes``) for that particular output. | |||
:issue:`8093` by :user:`Peter Bull <pjbull>`. | |||
|
|||
- Deprecate the ``fit_params`` constructor input to the | |||
- Deprecate the ``fit_params`` constructor input to the |
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.
Refrain from making changes that are not related to your PR.
doc/whats_new.rst
Outdated
|
||
- Deprecate the ``Y`` parameter from ``transform`` method signature in | ||
:class:`sklearn.cluster.birch` :class:`sklearn.cluster.k_means_` :class:`sklearn.decomposition.base` :class:`sklearn.decomposition.dict_learning` :class:`sklearn.decomposition.fastica_` :class:`sklearn.decomposition.pca` :class:`sklearn.feature_extraction.dict_vectorizer` :class:`sklearn.feature_extraction.hashing` :class:`sklearn.feature_extraction.text` :class:`sklearn.kernel_approximation` :class:`sklearn.neighbors.approximate` :class:`sklearn.preprocessing._function_transformer` :class:`sklearn.preprocessing.data` :class:`sklearn.random_projection` | ||
The method should not accept ``Y`` parameter, as ``transform()`` is used at the prediction time. ``Y`` parameter is deprecated on this version and will be removed in 0.21. |
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 line is way too long.
No need to say when it will be removed.
doc/whats_new.rst
Outdated
* 1 Andrew Ash | ||
* 1 Pietro Zambelli | ||
* 1 staubda | ||
* 312 Olivier Grisel |
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 review your diffs and do not change anything not related to your PR.
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.
Pushed by mistake, I am reverting changes.
1851028
to
83a6c27
Compare
As further discussed on thread #8174, the parameter
Y
in methodtransform()
will be deprecated and eventually removed in a future version .The method
transform()
has been used in the following:I didn't change this one, as Y is used.
I have added deprecation message