-
-
Notifications
You must be signed in to change notification settings - Fork 25.2k
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
MAINT Add one-sided set differences for clarity in param validation #23772
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.
LGTM
Usually I run |
@jeremiedbb Should be good now? |
I'm having second thoughts. I don't think that If a one writes a custom estimator that inherits from a sklearn estimator and calls class MyEstimator(KMeans):
def __init__(self, <all KMeans params>, additional_param):
...
def fit(self, X, y=None):
# do some extra stuff
super().fit(X, y) # <- calls self._validate_params and fails because
# additional_param is not in _parameter_constraints To not break user code (e.g. ImbalanceLearn maybe ? @glemaitre), I'd be in favor of being conservative and only validate params that are in the dict. We can still raise if a key in the dict doesn't correspond to any of the parameters. For scikit-learn estimators we still want to make sure that there's a 1-to-1 match, which should be ensured by the common test. |
@jeremiedbb is right. I can think of some predictor like It could be great to not impose it on third-party estimators for the moment. |
Updated this PR to implement this behavior. I added a list of unexpected/excess parameters to the error message as well to make it more informative. I moved the two set differences to the assertion error message in Edit: To clarify, in this PR the |
I agree with not being strict for third party estimators and being strict for scikit-learn estimators. |
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. Just a few remaining nitpcks
Co-authored-by: Jérémie du Boisberranger <[email protected]>
@glemaitre Are you happy with the changes made after you first approved? |
@glemaitre @jeremiedbb Sorry for the spam, just wanted to follow up on this :) |
Still good on my side |
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 as well.
…cikit-learn#23772) Co-authored-by: Jérémie du Boisberranger <[email protected]>
Reference Issues/PRs
Fixes #23744
What does this implement/fix? Explain your changes.
Add one-sided set differences for clarity in param validation
Any other comments?