-
-
Notifications
You must be signed in to change notification settings - Fork 26.5k
MNT Param validation: Make it possible to mark a constraint as hidden #23558
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: Make it possible to mark a constraint as hidden #23558
Conversation
sklearn/linear_model/_base.py
Outdated
| _parameter_constraints = { | ||
| "fit_intercept": [bool], | ||
| "normalize": [StrOptions({"deprecated"}, internal={"deprecated"}), bool], | ||
| "normalize": [Internal(StrOptions({"deprecated"})), bool], |
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.
For developer ergonomics, Internal looks very similar to Interval. (At a glance, I thought it was Interval). What do you think of renaming Interval to Range?
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 kind of prefer Interval, and range being a python keyword I think it could also bring confusion. Maybe we can change Internal instead. What do you think about Private or Hidden ?
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 am +1 for Hidden
glemaitre
left a comment
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 am fine with the rest of the PR.
glemaitre
left a comment
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
| "n_init": [ | ||
| StrOptions({"auto", "warn"}, internal={"warn"}), | ||
| StrOptions({"auto"}), | ||
| Hidden(StrOptions({"warn"})), |
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.
The alternative is StrOptions({"warn"}, hidden=True), but then we would need _InstancesOf "public", to do InstancesOf(Criterion, hidden=True). Also all the other constraints will have to be "public" to be configured to hide.
With that in mind, I'm okay with the PR as is.
thomasjpfan
left a comment
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
@glemaitre This PR changed a little bit since your approval. Do you want to take another look?
|
Still LGTM. Merging. |
Some parameters accepts types as an unofficial way. For instance
criterionin trees can be an instance ofCriterionbut that's not documented and not meant to be documented.For these, we don't want the error message of the validation of this parameter to say that this unofficial type is valid. Hence this PR proposes to make it possible to mark a constraint as
internalsuch that it's not shown in the message.