-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
MNT Param validation: Allow to skip validation of a parameter #23602
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
MNT Param validation: Allow to skip validation of a parameter #23602
Conversation
I don't exactly know what would be the best. |
Thank you, @jeremiedbb. To me, specifying the string |
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.
I think about it again and I think that as a first step this is fine to have "no validation". We can subcategories later on if we see that "no validation" is to wide (and introduce for instance "delegate", etc.).
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.
I'm okay with adding a "no_validation" constraint.
Minor comment, otherwise, LGTM
sklearn/utils/_param_validation.py
Outdated
@@ -44,6 +45,10 @@ def validate_parameter_constraints(parameter_constraints, params, caller_name): | |||
|
|||
for param_name, param_val in params.items(): | |||
constraints = parameter_constraints[param_name] | |||
|
|||
if constraints == ["no validation"]: |
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.
Minor nit: For the some consistency with _validate_data
if constraints == ["no validation"]: | |
if constraints == ["no_validation"]: |
I agree with @jjerphan's comment. |
Changed to string "no_validation" not in a list after irl discussion with @glemaitre who agreed with my last comment. |
Thanks @jeremiedbb LGTM |
For some parameters, we may want to skip validation, delegating it to the actual consumer of the param.
An example is the
dtype
parameter ofOneHotEncoder
, see #23579. Numpy dtype can be expressed in many different ways and we don't necessarily want to list them all here and keep it up to date. Instead we want to delegate validation to numpy since we don't deal withdtype
but directly pass it to numpy/scipy functions.I propose to allow specifying
["no validation"]
as constraint for a parameter to skip validation for this parameter. It could also just be the string"no validation"
(not in a list) to make it extra explicit that it's not even a constraint.Alternatives can be
["any"]
to express that anything is valid, or"delegate validation"
maybe. I'm wide open to suggestions.cc/ @thomasjpfan @glemaitre