-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
FIX Remove validation for FeatureUnion from __init__ #21954
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
Co-authored-by: arisayosh <15692997+arisayosh@users.noreply.github.com> Co-authored-by: iofall <50991099+iofall@users.noreply.github.com>
fs = FeatureUnion([("transform", Transf()), ("no_transform", NoTrans())]) | ||
with pytest.raises(TypeError, match=msg): | ||
FeatureUnion([("transform", Transf()), ("no_transform", NoTrans())]) | ||
fs.fit(X) |
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.
We noticed while working on this PR that the transform
method is not checked which is the intended check for this test. We tried using fit_transform()
but it also has a skip case defined which allows it to work without a transform
method.
Wondering if this should be fixed in a separate issue?
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.
The test is checking that during fit
or fit_*
, the __init__
parameters are valid. NoTrans
does not define a transform
method so FeatureUnion
should raise an error.
By convention, fs.transform
does not validate __init__
parameters.
skip case defined which allows it to work without a transform method.
May you clarify what you mean by "skip 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.
Thank you for clearing this 👍. On reading your comments and revisiting this, there seems to be no problem. There is no skip case, the _validate_transformers()
method does go through all the validation as required by the test.
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.
Thank you for the PR @iofall !
Please add an entry to the change log at doc/whats_new/v1.1.rst
with tag |Fix|
. Like the other entries there, please reference this pull request with :pr:
and credit yourself (and other contributors if applicable) with :user:
.
fs = FeatureUnion([("transform", Transf()), ("no_transform", NoTrans())]) | ||
with pytest.raises(TypeError, match=msg): | ||
FeatureUnion([("transform", Transf()), ("no_transform", NoTrans())]) | ||
fs.fit(X) |
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.
The test is checking that during fit
or fit_*
, the __init__
parameters are valid. NoTrans
does not define a transform
method so FeatureUnion
should raise an error.
By convention, fs.transform
does not validate __init__
parameters.
skip case defined which allows it to work without a transform method.
May you clarify what you mean by "skip 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.
Thank you for the update @iofall !
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.
Otherwise LGTM
doc/whats_new/v1.1.rst
Outdated
@@ -305,6 +305,10 @@ Changelog | |||
`__init__` but in `.fit()`. | |||
:pr:`21888` by :user:`iofall <iofall>` and :user: `Arisa Y. <arisayosh>`. |
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.
:pr:`21888` by :user:`iofall <iofall>` and :user: `Arisa Y. <arisayosh>`. | |
:pr:`21888` by :user:`iofall <iofall>` and :user:`Arisa Y. <arisayosh>`. |
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.
Thank you for the feedback I have made these changes!
doc/whats_new/v1.1.rst
Outdated
@@ -305,6 +305,10 @@ Changelog | |||
`__init__` but in `.fit()`. | |||
:pr:`21888` by :user:`iofall <iofall>` and :user: `Arisa Y. <arisayosh>`. | |||
|
|||
- |Fix| :class: `pipeline.FeatureUnion` does not validate hyper-parameters in | |||
`__init__`. Validation is now handled in `.fit()` and `.fit_transform()`. | |||
:pr:`21954` by :user:`iofall <iofall>` and :user: `Arisa Y. <arisayosh>`. |
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.
:pr:`21954` by :user:`iofall <iofall>` and :user: `Arisa Y. <arisayosh>`. | |
:pr:`21954` by :user:`iofall <iofall>` and :user:`Arisa Y. <arisayosh>`. |
Co-authored-by: iofall <50991099+iofall@users.noreply.github.com> Co-authored-by: arisayosh <15692997+arisayosh@users.noreply.github.com>
…nto Issue-21406-FeatureUnion
Thanks @iofall |
@@ -508,8 +508,8 @@ Changelog | |||
|
|||
- |Fix| :class: `pipeline.FeatureUnion` does not validate hyper-parameters in | |||
`__init__`. Validation is now handled in `.fit()` and `.fit_transform()`. | |||
:pr:`21954` by :user:`iofall <iofall>` and :user:`Arisa Y. <arisayosh>`. | |||
:pr:`21888` by :user:`iofall <iofall>` and :user:`Arisa Y. <arisayosh>`. | |||
:pr:`21954` and :pr:`21888` by :user:`iofall <iofall>` 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.
@glemaitre, I realize after seeing this change that I had accidentally left the line for :pr:21888
. Sorry about that. This line should only be:
:pr:`21954` by :user:`iofall <iofall>` and :user:`Arisa Y. <arisayosh>`.
How should we fix this? Should I add the commit on this PR or create a new 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.
Oh I see no worries. I will make a small doc fix in main
.
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.
FYI, it will be fixed in #22347
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.
Thank you!
Addresses #21406
What does this implement/fix? Explain your changes.
self._validate_transformers()
from__init__
.self._validate_transformers()
is already called in_parallel_func()
which is used by bothfit()
andfit_transform()
__init__
cc: @arisayosh