8000 FIX Removes validation in __init__ for Pipeline by arisayosh · Pull Request #21888 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

FIX Removes validation in __init__ for Pipeline #21888

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

Merged
merged 5 commits into from
Dec 10, 2021

Conversation

arisayosh
Copy link
Contributor

Reference Issues/PRs

Relates to issue #21406

What does this implement/fix? Explain your changes.

  1. Removed validation from __init__ by removing self.__validate_steps()
  2. Modified test_pipeline_init function in test_pipeline.py to test in .fit() instead of __init__

Any other comments?

Curious if we should instead create another function test_pipeline_fit for our changes since we are testing some of the parameters during fit and not init.

arisayosh and others added 2 commits December 5, 2021 11:20
Co-authored-by: arisayosh <15692997+arisayosh@users.noreply.github.com>
Co-authored-by: iofall <50991099+iofall@users.noreply.github.com>
…tion

Co-authored-by: arisayosh <15692997+arisayosh@users.noreply.github.com>
Co-authored-by: iofall <50991099+iofall@users.noreply.github.com>
Copy link
Member
@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

Thank for the pull request! Can you please update the tests to check that the exceptions can only be raised in the fit method below?

Also document this change in the doc/whats_new/v1.1.rst by taking example to other PRs that address part of #21406.

@@ -168,17 +168,17 @@ def predict_log_proba(self, X, got_attribute=False):
def test_pipeline_init():
# Test the various init parameters of the pipeline.
with pytest.raises(TypeError):
Pipeline()
Pipeline().fit([[1]], [1])
Copy link
Member

Choose a reason for hiding this comment

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

Can you please rewrite those test to make it explicit that the error is raised in fit?

    pipeline = Pipeline()
    with pytest.raises(TypeError):
        pipeline.fit([[1]], [1])

Copy link
Contributor Author
@arisayosh arisayosh Dec 7, 2021

Choose a reason for hiding this comment

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

Hi @ogrisel, thank you for reviewing. Would you like me to edit so that the above is done for each instance of pipeline in the test file?

Copy link
Member

Choose a reason for hiding this comment

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

Yes.

@arisayosh
Copy link
Contributor Author

Thank you @ogrisel for the review. Will fix the changes and document them in that file.

What are your thoughts on creating a new test function for those that are tested in .fit()?

8000

@ogrisel
Copy link
Member
ogrisel commented Dec 7, 2021

What are your thoughts on creating a new test function for those that are tested in .fit()?

That's a very good point. test_pipeline_init is a bad test for checking exception raised in fit on invalid paramaters. Let's move those assertions to a dedicated test named test_pipeline_invalid_parameters.

arisayosh and others added 2 commits December 8, 2021 08:52
to changelog

Co-authored-by: arisayosh <15692997+arisayosh@users.noreply.github.com>
Co-authored-by: iofall <50991099+iofall@users.noreply.github.com>
@@ -165,20 +165,23 @@ def predict_log_proba(self, X, got_attribute=False):
return self


def test_pipeline_init():
# Test the various init parameters of the pipeline.
def test_pipeline_invalid_parameters():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed function since we are not validating parameters during instantiation. We decided not to split the function in two because it caused code repetition.

@arisayosh arisayosh changed the title [WIP] ENH Removes validation in __init__ for Pipeline FIX Removes validation in __init__ for Pipeline Dec 8, 2021
Copy link
Member
@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the PR @arisayosh!

Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Copy link
Member
@thomasjpfan thomasjpfan left a 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 @arisayosh !

LGTM

@thomasjpfan thomasjpfan merged commit 0110921 into scikit-learn:main Dec 10, 2021
@arisayosh
Copy link
Contributor Author

This was a combined effort with @iofall! Thank you for the reviews @ogrisel and @thomasjpfan :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0