8000 [MRG] Relax init parameter checks and add explanatory error messages by timokau · Pull Request #17936 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[MRG] Relax init parameter checks and add explanatory error messages #17936

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 3 commits into from
Aug 7, 2020

Conversation

timokau
Copy link
Contributor
@timokau timokau commented Jul 16, 2020

Reference Issues/PRs

Fixes #17756.

What does this implement/fix? Explain your changes.

See #17756. The init parameter checks were unnecessarily restrictive to achieve the goal of checking for immutability. The error messages were also not very helpful when debugging failures, since they simply pointed to failed asserts without explaining which parameter is responsible or why it should have one of the whitelisted types.

@timokau timokau force-pushed the relax-init-parameter-checks branch from 5aeae49 to dfa6bac Compare July 16, 2020 15:11
@timokau timokau changed the title Relax init parameter checks and add explanatory error messages [WIP] Relax init parameter checks and add explanatory error messages Jul 16, 2020
@timokau timokau force-pushed the relax-init-parameter-checks branch 2 times, most recently from a9d929f to 1639a4e Compare July 16, 2020 16:42
timokau added 2 commits July 16, 2020 19:08
We now allow any "type" (uninitialized classes) and all numeric numpy
types. See scikit-learn#17756 for
a discussion.
This can make it much easier to work with this test while making a
pre-existing estimator compatible.
@timokau timokau force-pushed the relax-init-parameter-checks branch from 1639a4e to 1e7abee Compare July 16, 2020 17:08
@timokau timokau changed the title [WIP] Relax init parameter checks and add explanatory error messages [MRG] Relax init parameter checks and add explanatory error messages Jul 16, 2020
@rth rth self-requested a review July 17, 2020 22:41
Copy link
Member
@rth rth left a comment

Choose a reason for hiding this comment

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

Thanks @timokau ! Generally looks good, however could you please add a test to sklearn/utils/tests/test_estimator_checks.py that check that,

  • on a very simple estimator similar to the example in your issue, that check_parameters_default_constructible now passes
  • on a simple estimator that would take as input some instance of a class, this estimator would fail.

@timokau timokau force-pushed the relax-init-parameter-checks branch 3 times, most recently from 7905839 to 659bea4 Compare August 1, 2020 14:33
@timokau timokau force-pushed the relax-init-parameter-checks branch from 659bea4 to 8c6c313 Compare August 1, 2020 15:12
@timokau
Copy link
Contributor Author
timokau commented Aug 1, 2020

I didn't think the tests had their own tests 😄

Done. Please have another look.

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 @timokau !

LGTM

Copy link
Member
@rth rth 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 @timokau !

@rth rth merged commit 86101d7 into scikit-learn:master Aug 7, 2020
@timokau timokau deleted the relax-init-parameter-checks branch August 7, 2020 18:00
jayzed82 pushed a commit to jayzed82/scikit-learn that referenced this pull request Oct 22, 2020
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.

Init parameter check of estimator_checks overly restrictive
3 participants
0