-
-
Notifications
You must be signed in to change notification settings - Fork 26k
MAINT validate parameters for MLPRregressor and MLPClassifier #23789
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 validate parameters for MLPRregressor and MLPClassifier #23789
Conversation
@Jitensid I let you check the failure of the CI before making a review such that you can correct the code accordingly. |
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.
Thanks for the PR @Jitensid. Here's a first pass.
Some of the CI failures are more subtle. I'll take a look
Thank for the suggestions @jeremiedbb and @glemaitre |
The current error is due to the common test checking for If we don't care about potentially calling |
…egressor_and_mlpclassifier_uses_validate_params
Thank you @Micky774 I have found the cause of the failure of tests as pointed by you. As of right now I have added |
…egressor_and_mlpclassifier_uses_validate_params
I pushed a small refactoring to avoid repeated validation in partial_fit, and fixes some small mistakes I found in the constraint definitions. |
Thank you |
@@ -1606,3 +1563,25 @@ def _validate_input(self, X, y, incremental, reset): | |||
if y.ndim == 2 and y.shape[1] == 1: | |||
y = column_or_1d(y, warn=True) | |||
return X, y | |||
|
|||
@available_if(lambda est: est._check_solver) |
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 should avoid the lambda
here. It will not be possible to pickle then.
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.
Should be fine after #23077
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
Thanks @Jitensid |
…-learn#23789) Co-authored-by: jeremie du boisberranger <[email protected]>
…-learn#23789) Co-authored-by: jeremie du boisberranger <[email protected]>
Reference Issues/PRs
MLPRegressor and MLPClassifier uses _validate_parameters as part of #23462
What does this implement/fix? Explain your changes.
MLPRegressor
andMLPClassifier
estimators base classBaseMultilayerPerceptron
has a new class attribute_parameter_constraints
that defines the valid types and values for the parameters.partial_fit
andfit
methods first call the self._validate_params() method.Any other comments?
Some tests are failing and need some help in them.